Free debugging puzzles for ages 10–13. Read small JavaScript-style programs, trace them with a variable table, spot the broken line and pick the fix.
The routine for each program
A level serves up three short programs. Each comes with a goal (“print the sum of the numbers from 1 to 9”) and the exact output it should give. Hidden inside the code is a bug.
- Run. The Run button plays the entire program. Step advances one line each press. Whatever the program prints appears in the output panel.
- Compare. A mismatch with the expected output means the code is wrong somewhere.
- Trace. The watch table lists all variables after every step. Fresh values glow, so you can watch a total jump the wrong way or a loop end a round early.
- Point at the culprit. Tapping a sound line gets the reply “this line is fine”. Tapping the faulty line opens a short menu of repairs.
- Pick a repair. Each bad choice displays what it would print, which can teach nearly as much as the good one. The right repair goes in, the program reruns, and the output turns green.
| Levels | Programs | Typical bugs |
|---|---|---|
| 1–4 | Variables and arithmetic | Wrong operator, missing brackets, a value computed but never stored |
| 5–8 | Loops | Off-by-one (< vs <=), a counter that never changes, a loop that never ends |
| 9–12 | Loops with if | Wrong remainder test, > instead of >=, "i" in quotes instead of the variable |
| 13–16 | Lists and text | Reading past the end of a list, position vs value (i vs nums[i]) |
| 17–20 | Two bugs per program | Fix one, rerun, and track down the second |
Numbers, words and lists change at random, so a replay offers fresh programs.
Skills at work
Programmers write code, but they also read it, and reading is the focus here: working through each line and knowing precisely what it does.
Following a loop while i and sum change reveals what loops actually do. Many young coders can describe loops yet are startled to learn that i < 5 ends at 4. One look at the table settles it.
The bugs on offer are everyday ones: off-by-one slips, grabbing a position instead of the value stored there, computing a result and not saving it, swapping + and *, or typing a variable name as plain text. Spotting such patterns makes a child’s own programs more reliable.
There is a hint of science too. A guess such as “the loop quits too early” can be tested with Step and confirmed by the output, and bad repairs still show results, so every attempt yields evidence.
Because mistakes cost stars rather than the level, children learn to slow down and verify instead of guessing.
Coaching tips
Ask your child to predict the printout before pressing Run, then compare. Encourage stepping through at least one loop per level while naming the counter’s value out loud. When a repair option shows its output, ask why that result is wrong, since explaining a mistake teaches a lot. The two-bug levels are demanding, so any finish deserves praise.
Offline versions
- Faulty directions. Write a recipe or a route with one planted error and have your child find it.
- Paper trace table. Try “start at 1, double five times” and fill a two-column table of step and value on paper, which is the watch table’s job.
- Role swap. Invite your child to write a small program with a secret bug for you to find. Planting a good one takes deep understanding.
Typical slips
Children sometimes tap lines before running anything, yet the output is the main clue. They may also assume the bug sits where the answer is printed, though trouble often begins earlier. And list positions start at 0, which catches nearly everyone once.