Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Double All Async

Asynchronous JavaScriptmedium

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

Implement `doubleAllAsync(nums)` that resolves each doubled value and returns them with `Promise.all`.

Sample tests

Input: doubleAllAsync([1,2,3])
Output: [2,4,6]
Input: doubleAllAsync([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Returning an array of promises instead of awaiting/returning Promise.all.

Learning resources

  • MDN: Promise
Visualize this concept: Microtasks vs. Macrotasks →
Approach & explanation (try first)

Promise.all over the mapped doubled promises resolves to the array of doubled numbers.

Loading...
⌘/Ctrl + Enter

Run your code to see results.