Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Await in Sequence

Asynchronous JavaScriptmedium

Course · Section 16: Asynchronous JavaScript: Promises, Async/Await, and AJAX · Lecture 265: Chaining Promises

Implement an async function `runInOrder(nums)` that awaits each value in turn and returns them collected in order.

Sample tests

Input: runInOrder([1,2,3])
Output: [1,2,3]
Input: runInOrder([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Sequential awaits are slower than Promise.all when order does not matter.
Visualize this concept: The Event Loop →
Approach & explanation (try first)

Awaiting inside the loop processes each value in order before moving on.

Loading...
⌘/Ctrl + Enter

Run your code to see results.