Hard
JS-004javascriptImplement Promise.all
Problem
Write `myAll(promises)` that returns a promise resolving to the array of results in input order, OR rejects with the first rejection. Without using Promise.all.
Input
N/A — script demo.
Output
JSON.stringify of the resolved array (or 'error: ...').
Constraints
1 ≤ promises.length ≤ 10^3
Sample input
[resolve(1), resolve(2), resolve(3)]
Sample output
[1,2,3]
Explanation
All resolve → array of values in the same order as inputs.
promisesasyncdesign@Google@Uber@Stripe
Visible test cases
in: [resolve(1), resolve(2)]
out: [1,2]
in: [reject('X'), resolve(2)]out: error: X
Your solution — run it, use AI if stuck
javascript
