Skip to the content

Reading an error

JavaScript · Unit 9: Errors and exceptions

When something goes wrong, JavaScript stops and tells you three things: the error type, a message and the line.

In ReferenceError: totl is not defined (line 3), the type is ReferenceError, the message says totl doesn't exist, and the line tells you where to look.

The rest of the explanation is in the lesson, which is part of the full plan.

Exercises in this lesson

You do them in the app, which checks them on the spot and explains why.

  1. 1. Multiple choice

    You get this error: TypeError: name.toUpper is not a function. Which part is the error type?

  2. 2. Multiple choice

    You get ReferenceError: pirce is not defined on line 2. What happened?

  3. 3. Find the bug

    Running this gives ReferenceError: totl is not defined. It should print the total, 90. Which line has the error?

  4. 4. Find the bug

    This program should print "Hello" and then "Emma". Which line has the error?

  5. 5. Multiple choice

    If you delete the closing quote on line 3, leaving console.log("three);, what happens when you run it?

  6. 6. Find the bug

    This program should print the grocery list, one item per line. Which line has the error?

  7. 7. Multiple choice

    Now the change is different: on line 3 you write console.log(three);, without quotes. What happens when you run it?

  8. 8. Put the lines in order

    Order the lines to print the bill with a 10% tip, without getting a ReferenceError.

  9. 9. Complete the code

    This code gave ReferenceError: ages is not defined on line 2. Complete line 1 to fix it.

  10. 10. Find the bug

    You get ReferenceError: total is not defined on line 3. The variable should be called total. Which line has the error?

Do this lesson

It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.

See all lessons →