Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Promise.allSettled Statuses

Asynchronous JavaScripthard

Course · Section 16: Asynchronous JavaScript: Promises, Async/Await, and AJAX · Lecture 278: Other Promise Combinators: race, allSettled and any

Implement an async function `collectStatuses(flags)` where each boolean creates a resolved (true) or rejected (false) promise. Use `Promise.allSettled` and return the array of `status` strings.

Sample tests

Input: collectStatuses([true,false,true])
Output: ["fulfilled","rejected","fulfilled"]
Input: collectStatuses([true])
Output: ["fulfilled"]

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Promise.all would reject as soon as one promise rejects.
Visualize this concept: Promises →
Approach & explanation (try first)

allSettled waits for every promise and reports each outcome's status, unlike all which rejects early.

Loading...
⌘/Ctrl + Enter

Run your code to see results.