JavaScript Promise.all — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Promise.all lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Wait for two promises
easy10 minUse Promise.all and report both values joined by a comma.
- 2
Keep the input order
easy10 minShow that results follow the input order, not the finishing order.
- 3
Handle one failure
easy10 minCatch the rejection that Promise.all passes on.
- 4
Report every outcome
easy10 minUse allSettled and report the two statuses joined by a comma.
- 5
Take the first to finish
medium10 minUse Promise.race and report the quicker value.
Find the bug(5)
- 1
Fix the promises awaited one at a time
easy8 minIndependent work should run together with Promise.all.
- 2
Fix the array not passed
easy8 minPromise.all takes one array, not separate arguments.
- 3
Fix all used where allSettled is needed
easy8 minOne rejection loses every result, but each outcome is wanted.
- 4
Fix the results sorted by finishing time
easy8 minPromise.all already returns them in input order.
- 5
Fix race used where all is needed
easy8 minEvery value is wanted, not just the first to arrive.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace