Practice: Fix the Broken Code

Each step has DOM code that almost works — but one specific bug stops it. Spot the bug, type the fix into the blank, and learn the kinds of mistakes every developer hits.

Step 1 of 8

Bugs are how you really learn

Every working line of code you have ever seen was once broken. The difference between a beginner and a senior is not that the senior writes perfect code — it is that they recognise familiar bugs and know where to look.

In this lesson, each step shows DOM code that almost works. One specific token has been replaced with a blank. Read the comment above the snippet — it tells you what the code is supposed to do. Spot the bug, type the correct token into the blank.

Think of it this way: Think of it like spotting a typo on a printed sign. The sign almost says the right thing, but one letter is off. Fix the letter and the sign reads cleanly again.
Tip

When a real DOM script silently does nothing, the bug is usually one of these: a typo in a method name, a wrong selector, a missing .value, a forgotten preventDefault(), or a bad event name.