JavaScript Errors — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript 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 failure
easy10 minCatch the error and report a message.
- 2
Carry on afterwards
easy10 minShow that the program continues after a caught error.
- 3
Read the error name
easy10 minReport the name of the error that was thrown.
- 4
Read the error message
easy10 minReport the message of an error you throw yourself.
- 5
Let an error travel up
medium10 minCatch at the top an error thrown two functions down.
Find the bug(5)
- 1
Fix the missing try block
easy8 minWithout a try the error stops everything after it.
- 2
Fix the message read as a name
easy8 minThe name is the type; the message is the description.
- 3
Fix the logic error treated as catchable
easy8 minWrong brackets do not throw, so try cannot help.
- 4
Fix the catch placed too deep
easy8 minThe inner function swallows an error the caller needed to see.
- 5
Fix the code placed after the failure
easy8 minStatements after the throwing line inside try never run.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace