Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Promise.all (Parallel)

Asynchronous JavaScriptmedium

Course · Section 16: Asynchronous JavaScript: Promises, Async/Await, and AJAX · Lecture 277: Running Promises in Parallel

Implement an async function `tripleAll(nums)` that resolves each tripled value and returns them all with `Promise.all`.

Sample tests

Input: tripleAll([1,2,3])
Output: [3,6,9]
Input: tripleAll([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • awaiting in a loop runs them sequentially instead of in parallel.
Visualize this concept: Microtasks vs. Macrotasks →
Approach & explanation (try first)

Promise.all resolves all the tripled-value promises together and returns the array of results.

Loading...
⌘/Ctrl + Enter

Run your code to see results.