An uncaught error stops the script
The heading says "Line 2 ran": everything before the error happened, nothing after it did.
When JavaScript can't do what you asked, it creates an error object with a name, a message and a stack trace; the name (SyntaxError, ReferenceError, TypeError, RangeError and a few more) tells you what kind of mistake it is, and the stack trace tells you where.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write code that triggers a RangeError from "ab".repeat(-1), catches it, and prints only its name.
This function crashes for one of the three users. Without running it, say which error and for which user, then fix it so it prints No email for that user: const users = [{ email: "a@x.in" }, { email: "b@x.in" }, {}]; users.forEach((u) => console.log(u.email.toLowerCase()));
Explain it without notes
What are the main built-in error types, and what does each one tell you?
What is the difference between a SyntaxError in your script and one from JSON.parse?
How do you read a stack trace, and why isn't the top line always the bug?
Why shouldn't your code depend on the text of an error message from the engine?
Preview
Console
Nothing logged yet.Expected console output
Line 1 runs
Uncaught TypeError: Cannot read properties of null (reading 'name')