JavaScript Promise Errors — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Promise Errors 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
Catch a rejection
easy10 minCatch a rejected promise and report the message.
- 2
Catch a thrown error
easy10 minThrow inside a then and catch it.
- 3
Clean up with finally
easy10 minHandle a rejection then report that cleanup ran.
- 4
Check the error type
easy10 minReport whether the rejection reason is an Error object.
- 5
Recover from a failure
medium10 minCatch a rejection and continue the chain with a fallback value.
Find the bug(5)
- 1
Fix the missing catch
easy8 minThe rejection is never handled, so nothing is reported.
- 2
Fix the message read from a string
easy8 minA rejection reason that is a plain string has no message property.
- 3
Fix finally expected to receive a value
easy8 minfinally gets no argument; the value passes straight through.
- 4
Fix the throw outside the chain
easy8 minA throw outside a promise handler is not caught by catch.
- 5
Fix the chain that stops at the catch
easy8 minThe catch should return a value so the next step can use it.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace