Problem List|9. Custom Promise.all PolyfillMedium

9. Custom Promise.all Polyfill

Promises & AsyncJavaScript Core
Implement a polyfill for `Promise.all`. The function `promiseAll(promises)` accepts an array of promises (or values) and returns a new Promise that: 1. Resolves when all input promises have resolved, returning an array of resolved values in the original order. 2. Rejects immediately if any input promise rejects with that error. 3. If passed an empty array, resolves immediately with an empty array.
Example 1:
Input: promises = [1, 2, 3]
Output: [1, 2, 3]
Explanation: All values resolve and maintain their input index order.

Constraints:

  • Input can be an array of Promises, primitives, or mixed values.
Integrity: 100%
Loading...
Input Arguments:
promises = [1, 2, 3]
Expected Output:
[1, 2, 3]