Implement Promise.allSettled from scratch
When you save six form sections at once, Promise.all throws away five results the moment one fails. allSettled waits for all of them and describes each outcome so the UI can mark exactly which section needs attention.
Implement allSettled(promises) without using Promise.allSettled. It resolves with an array in input order, one entry per input. A fulfilled input produces an object with exactly two properties, status: "fulfilled" and value. A rejected input produces an object with exactly two properties, status: "rejected" and reason. Non-promise entries count as fulfilled. The returned promise never rejects, and an empty array resolves with an empty array.
What it has to do
- Resolve with one entry per input, in input order.
- Use exactly the keys
statusandvaluefor a fulfilled entry. - Use exactly the keys
statusandreasonfor a rejected entry. - Never reject, even when every input rejects.
- Resolve with
[]for an empty array.
Your workspace
Ready to check it?
4 tests run against your code, right here in your browser. Sign in to claim the XP when you pass.
AI Crack & Solution Assist
Stuck? Get instant AI hints or break down the optimal solution.
Stuck? The javascript course covers everything this challenge needs.