Reimplementing Promise.all is the canonical async question. It checks that you understand ordering, the empty case, and that inputs aren't always promises.
results[i], never results.push.[].Promise.resolve.Promise.allSettled." → never reject; store { status, value | reason } for each.Promise.race?" → resolve/reject with whichever settles first; no counting.Promise.any?" → resolve on first fulfilment, reject only if all reject (AggregateError).Implement all, then allSettled and race — they're frequently asked together.
function promiseAll(promises) { // your code here } promiseAll([Promise.resolve(1), 2, Promise.resolve(3)]) .then((r) => console.log(r)); // [1, 2, 3]
Test Code
Enter JavaScript that runs after your solution. It should return a value or a Promise.