Quizzesasync / await — Promises That Read Like Sequential Code — Concept Check
intermediate
javascript

async / await — Promises That Read Like Sequential Code — Concept Check

Questions on async / await — Promises That Read Like Sequential Code. async functions always return a promise; await pauses inside them until a promise settles. It is syntax over promises, so everything about promises still applies.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on async / await — Promises That Read Like Sequential Code — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer notices that their async function is returning a pending Promise instead of the expected value. What is the most likely cause?

    • AThey forgot to use await when calling the function.
    • BThe function does not handle errors properly.
    • CThey used await inside a loop incorrectly.
    • DThe function is missing a return statement.
  2. 2.In an async function, what happens if an error occurs and there is no try/catch block?

    • AThe program crashes immediately.
    • BThe error is logged automatically.
    • CThe function returns a rejected Promise.
    • DThe error is silently ignored.
  3. 3.A developer uses await inside a loop to fetch data for multiple IDs. What is a potential issue with this approach?

    • AIt fetches data in parallel, causing rate limits.
    • BIt automatically handles errors for each request.
    • CIt may cause data inconsistency.
    • DIt processes each request sequentially, increasing latency.
  4. 4.A module uses top-level await to load configuration data. What is a requirement for this to work?

    • AThe configuration data must be JSON.
    • BThe module must use CommonJS syntax.
    • CThe module must be imported synchronously.
    • DThe module must be an ES module.
  5. 5.A developer writes an async function but forgets to include await for a promise inside it. What is a consequence of this mistake?

    • AThe promise rejection becomes an unhandled rejection.
    • BThe function will return undefined.
    • CThe function will not execute.
    • DThe promise will automatically resolve.
  6. 6.What is a benefit of using async/await over .then chains in JavaScript?

    • AAsync/await allows synchronous execution of all code.
    • BAsync/await eliminates the need for error handling.
    • CAsync/await automatically retries failed promises.
    • DAsync/await makes asynchronous code look sequential.
  7. 7.When is it appropriate to use sequential execution with await inside a loop?

    • AWhen performance is not a concern.
    • BWhen order of execution matters.
    • CWhen each iteration is independent.
    • DWhen handling multiple promises.