Learning on Web Dev Open is free for all.

Interview Prep · CodeImplement Promise.all from scratch
← Code

Implement Promise.all from scratch

Easy20 minFree, no account

Ten lines, and three edge cases that separate a memorised answer from an understood one.


The question

Implement promiseAll(values) with the same semantics as Promise.all.

Then say how allSettled, race and any differ, and implement one of them.

promiseAll([p1, p2, p3]).then(([a, b, c]) => ...)

promiseAll([])            // resolves immediately with []
promiseAll([1, p, "x"])   // non-promises pass straight through
// rejects with the FIRST rejection, immediately
20:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Results in input order, written by index25
  • Explicit counter rather than inferring from the array25
  • Empty input resolves immediately20
  • Non-promise values handled15
  • Explained the family and what happens after a rejection15

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only