Skip to main content

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. 1

    Catch a failure

    easy10 min

    Catch the error and report a message.

  2. 2

    Carry on afterwards

    easy10 min

    Show that the program continues after a caught error.

  3. 3

    Read the error name

    easy10 min

    Report the name of the error that was thrown.

  4. 4

    Read the error message

    easy10 min

    Report the message of an error you throw yourself.

  5. 5

    Let an error travel up

    medium10 min

    Catch at the top an error thrown two functions down.

Find the bug(5)

  1. 1

    Fix the missing try block

    easy8 min

    Without a try the error stops everything after it.

  2. 2

    Fix the message read as a name

    easy8 min

    The name is the type; the message is the description.

  3. 3

    Fix the logic error treated as catchable

    easy8 min

    Wrong brackets do not throw, so try cannot help.

  4. 4

    Fix the catch placed too deep

    easy8 min

    The inner function swallows an error the caller needed to see.

  5. 5

    Fix the code placed after the failure

    easy8 min

    Statements 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