π Debugging for Kids
Debugging is being a detective for your code.
Bugs Are Normal
Code almost never works the first time. That's not because you're bad β it's just how it works. Even experts have bugs constantly.
Be a Detective
When something doesn't work: ask "what did I expect?" and "what actually happened?" The gap between them is the bug. Read error messages carefully β they're clues.
Print Things to Check
If you're not sure what your variable contains, print it! Add console.log(myVariable) and run again. The computer tells you the truth.
Talk to a Duck
Real coders sometimes explain their code to a rubber duck. Saying it out loud often reveals the bug. Yes, really.
Now you try! Find a bug in this English: "Step 1: Open the door. Step 2: Walk inside." (Hint: how do you get to the door?)
Parent/teacher tip: Make "what did I expect vs. what actually happened?" a regular question β it builds metacognition.