JavaScript Async
Implement Promise.all
mediumJS / TS
Problem Statement
Implement a custom `promiseAll` function that accepts an array of promises (or values) and returns a single Promise that resolves to an array of results, maintaining original order. If any promise rejects, `promiseAll` rejects with that error immediately.
Examples
Example:
const p1 = Promise.resolve(42);
const p2 = new Promise((resolve) => setTimeout(() => resolve('hello'), 100));
promiseAll([p1, p2]).then(console.log); // [42, 'hello']Includes TypeScript & JavaScript starter code
Start Interview with this Problem