promise.allSettled( )
Problem statement
Implement customPromiseAllSettled(promises), a version of Promise.allSettled.
It should wait for every promise to settle and always resolve with status objects.
How to approach promise.allSettled( )
The strategy an interviewer expects you to reach for.
allSettled is the dashboard version of fan-in: you want every job's outcome, even when some fail. A status widget must not vanish because one tile errored. Naive move Reuse Promise. all. One rejection nukes the whole batch and you lose the successes. Where it breaks Callers need { status, value } or { status, reason } per slot. Empty input still resolves to []. The outer promise must never reject. The fix For each input, attach both fulfill and reject handlers that write a settled descriptor at that index and bump a counter. When the counter hits length, resolve with the descriptors — never reject the outer promise. Remember: allSettled never rejects the outer promise; each slot carries its own status.
The full solution is part of HelloFrontend Pro
The question above is free to read in full. Upgrade to unlock the interactive workspace and the senior-level walkthrough that go with it.
- Runnable editor with the hidden test suite
- Progressive hints that unlock as you get stuck
- Senior-level reference solution with a line-by-line walkthrough
Already a member? Log in to open the workspace.