Problem Solving
Coding is 20% typing, 80% staring and asking “why”.
▶ the lesson · narrated sketch video · tap for sound
the intro
Problem solving is the actual job. The reliable loop: reproduce the bug, isolate the smallest failing case, form one hypothesis, change exactly one thing, test. Repeat until the mystery dies. Everything else is typing.
the sample
the oldest debugger in the world
console.log('here 1')
console.log('here 2')
// ...the classic
// it never prints 'here 2'fun fact ✦
Most “impossible” bugs are a typo you have stared at for two hours. Take the walk. Really.
the docs
the deep dive
the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid
Debugging is not a talent some people are born with — it is the scientific method with worse lighting. You observe (reproduce the bug), guess (one hypothesis), experiment (change exactly one thing), and conclude. The engineers who seem psychic at bugs are not reading minds; they have just run more experiments and kept better notes.
the scientific method with worse lighting
key terms
repro case
A recipe that makes the bug fail every single time. Without one you cannot test a fix, only hope.
save with an empty cart fieldhypothesis
One guessed cause, worded specifically enough to be proven wrong.
the id arrives as a stringbisect
Cut the suspects in half each round: the bug survives in one half, so the other half is cleared.
8 suspects becomes 4, then 2heisenbug
A bug that vanishes or changes the moment you try to observe it, like adding a console.log.
disappears with logs addedhow it works
- 1Nail the reproduction
Find steps that fail 100 percent of the time before touching any code. A bug you cannot summon, you cannot verify fixed.
- 2Shrink the failing case
Delete everything the bug does not need: one function, one input, one click. Smaller case, fewer suspects.
- 3State one hypothesis
Write the full sentence: I think X fails because Y. Vague guesses produce vague experiments.
- 4Change exactly one thing
Test. Same bug means revert and cross that suspect off the list. Fixed means you learned something real.
- 5Record the cause
One line on why it broke, not just the edit. Patterns repeat, and past you left notes.
the code, explained
the oldest debugger alive: it never prints rate, so the line above is guilty
side by side
change one thing
- each run clears or convicts one cause
- reverting is always safe
- you learn the system as you go
shotgun debugging
- five changes, none provably the fix
- cannot explain what worked
- new bugs land unnoticed
The scariest outcome is a fix you cannot explain. It passes today, the real bug is still in there, and it will pick the busiest week of the quarter to come back. If you cannot say why the fix works, keep digging.
quick answers
How long should I struggle before asking for help?
Timebox it: 30 to 60 minutes of going in circles is the signal. Bring your repro case and the hypotheses you already cleared — that list saves your helper an hour.
Debugger or console.log?
Both. Logs for quick checkpoints along a path, breakpoints for freezing state mid-flight and inspecting everything at once. Breakpoints beat forty print statements.
What if the bug is inside a library?
Same loop, one level up: pin the version, read its issue tracker, build the smallest project that shows it. Half the time the answer is an upgrade.
quick hits about Problem Solving
short answers · interviews, tips, trivia & hidden gems