en.javascript.info/1-js/11-async/08-async-await/03-async-from-regular/task.md
Herrera-pgoat 58ee49a958
Update task.md
Made it clear what the question was asking from the user.
2020-10-22 16:05:32 -05:00

510 B

Call async from non-async

We have a "regular" function called f. How can you call the async function wait() and use its result inside of f?

async function wait() {
  await new Promise(resolve => setTimeout(resolve, 1000));

  return 10;
}

function f() {
  // ...what should you write here?
  // we need to call async wait() and wait to get 10
  // remember, we can't use "await"
}

P.S. The task is technically very simple, but the question is quite common for developers new to async/await.