Steps
The Debugging Mindset
Think like a detective
Debugging is detective work. Something isn't working, and you need to find out why.
**The wrong approach:** - Change random things and hope it works - Get frustrated and start over - Assume the computer is broken
**The right approach:** 1. **Observe** — What exactly is happening? 2. **Hypothesize** — What might be causing it? 3. **Test** — Check if your hypothesis is correct 4. **Repeat** — Narrow down until you find it
**The key question:** "What did I expect to happen, and what actually happened?"
**Example:** - Expected: Button shows a popup when clicked - Actual: Nothing happens when I click - Hypothesis 1: The click handler isn't attached - Test: Add a console.log in the click handler - Result: Log doesn't appear → hypothesis confirmed!
Now you know WHERE the problem is.