Skip to content
dreamcode
dreamcode
Map
Launch Checklist
Section challenge · AdvancedJavaScript
Reward: +70 XP
PROBLEM

Launch Checklist

Before launch, every check in checks must run. Each number is one check: runCheck(ms, index) (already written) waits that many milliseconds and then passes, or fails with an error when the number is negative.

Write async function runChecklist(checks) that starts all checks at the same time, waits until every one has finished, and returns:

  • passed: how many checks passed
  • failed: the error messages of the failed checks, in the order of checks

One failing check must not stop the others from being counted.

Examples
runChecklist([5, 10, 1])
{ passed: 3, failed: [] }
runChecklist([5, -1, 3, -2])
{ passed: 2, failed: ["check 1 failed", "check 3 failed"] }
solution.js
JAVASCRIPT
Saved as you type

Tests

0 of 4 passing
  • all pass
    runChecklist([5, 10, 1])
    expected { passed: 3, failed: [] }
  • two fail
    runChecklist([5, -1, 3, -2])
    expected { passed: 2, failed: ["check 1 failed", "check 3 failed"] }
  • empty list
    runChecklist([])
    expected { passed: 0, failed: [] }
  • all fail
    runChecklist([-4, -1])
    expected { passed: 0, failed: ["check 0 failed", "check 1 failed"] }
On the line
+70 XP
Pass all 4 tests to claim it.