Lesson 1 of 8
Read the error message
- 12 min
- 4 checks
- 3 hints
- Go to task
Goal
The message tells you where to look
Explanation
An error message isn't a punishment. It's a report meant to help you, and it tells you three things: the type of error, what happened, and where it happened.
The message TypeError: Cannot read properties of null (reading 'textContent') means you tried to read a property of null. When that null comes from querySelector, the cause is usually a selector that doesn't match any element: a typo, a dot where you needed #, or a script that runs before the element exists.
The code below has mistakes of exactly this kind, and the console next to it tells you where they are.
Your task
Run the code and read what the console says, then fix the mistakes until the page works without any errors.
Checks
4 checks- The heading is selected by its id, not its tag name
- The button is selected by its class
- Clicking writes the result without an error
- The text comes from the right element