Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Sequential Accumulate

Asynchronous JavaScriptmedium

Course · Section 16: Asynchronous JavaScript: Promises, Async/Await, and AJAX · Lecture 263: Promises and the Fetch API

Implement an async function `accumulateAsync(nums)` that awaits each number in sequence and returns the total.

Sample tests

Input: accumulateAsync([1,2,3,4])
Output: 10
Input: accumulateAsync([])
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Sequential awaits are slower than Promise.all when order does not matter.

Learning resources

  • MDN: async function
Approach & explanation (try first)

Awaiting each value in sequence and accumulating gives the total, demonstrating for-await-style flow.

Loading...
⌘/Ctrl + Enter

Run your code to see results.