Even or odd

Report a typo

Sophia made an asynchronous function that takes a number as a parameter and after 2 seconds prints the result in the console.

async function evenOrOdd(number) {
  let promise = new Promise((resolve, reject) => {
    if (number % 2 === 0) {
      setTimeout(() => resolve('The number is even'), 2000);
    } else {
      setTimeout(() => reject('The number is odd'), 2000);
    }
  });

  ... 
  console.log(result);
}

As you can see, the function is incomplete. Sophia ended up forgetting to store the result in the constant result.

Select the part of the code that she missed.

Select one or more options from the list
___

Create a free account to access the full topic