Solution Review: Async & Await
In this lesson, we will discuss the solutions to the questions in the previous lesson.
Press + to interact
function func1(num) {return new Promise(function(resolve){setTimeout(function(){resolve(num);}, 1000);});}async function multiply(num) {const x = func1(10);const y = func1(3);return num * await x * await y;}multiply(10).then(function(result){console.log(result);});
For the code above, you had to answer the following question:
Explanation #
Run the code below to see the solution.
Press + to interact
function func1(num) {return new Promise(function(resolve){setTimeout(function(){resolve(num);}, 1000);});}async function multiply(num) {const x = func1(10);const y = func1(3);return num * await x * await y;}multiply(10).then(function(result){console.log(result);});
The code outputs 300
, making Option B the correct answer. ...
Access this course and 1400+ top-rated courses and projects.