Web Frontend Magic Quiz

Test your knowledge of Web Frontend by answering this quiz!
Question about JavaScript Promises

What is the value of winner after running the following code?

var tortoise = new Promise(
  function handler(resolve, reject) {
     setTimeout(function finishLine() {
        resolve('The winner is me, the tortoise');
     }, 5000);
  }
);

var hare = new Promise(
  function handler(resolve, reject) {
    setTimeout(function takeRest() {
       setTimeout(function sprint() {
         resolve('The winner is me, the hare');
       }, 1000);
    }, 5000);
  }
);

var winner;

Promise.race([tortoise, hare]).then(function onResult(w) {
  winner = w;
});


  • The winner is me, the tortoise
  • The winner is me, the hare
  • ['The winner is me, the tortoise', 'The winner is me, the hare']
  • This code will not run.
How do you stack up?
My Progress
Percentage of Total Answers Correct
0 / 0
0%

Breakdown by Tag
0 / 0
0%
Not sure about the answer? Check out:
JavaScript PromisesLast updated today