Skip to content
Aback Games

Bug Hunt

Spot the buggy line in short JavaScript, Python and SQL snippets. 8 a round, with the cause and the fix after each.

  • Developer game
  • Free
  • No sign-up
  • Keyboard
  • Touch
Code
Snippet0/8
Found0
Best–

JavaScriptWhich line has the bug?

Meant to: Add up every number in an array.

  1. function sum(numbers) {
  2. let total = 0;
  3. for (let i = 0; i <= numbers.length; i++) {
  4. total += numbers[i];
  5. }
  6. return total;
  7. }

Fixed

8 short snippets. Each has one line that breaks it. Find the line.

Click the line with the bug, or move with the arrow keys and press Enter. Then press Enter for the next snippet.Tap the line with the bug, then Next snippet.

Enjoying Bug Hunt? Share it:Post on X (opens in a new tab)

About Bug Hunt

Most bugs are not exotic. They are the same small mistakes, made again and again: a loop that runs once too often, a comparison with NULL, a default value that is shared between calls. Bug Hunt is practice at spotting them quickly, the way you would in a code review.

Each round has 8 short snippets. Every snippet says what it is meant to do and has exactly one line that stops it doing that. Pick the line. Then you see the bug, why it happens and the fixed line, so every snippet teaches you something even when you miss it.

How to play Bug Hunt

Bug Hunt controls

Keyboard
Move between linesUp and Down arrows (Tab reaches the code)
Pick a lineEnter or Space, or click it
Next snippetEnter (the Next button has focus)
New roundN
Sound on or offM
Touch screens
Pick a lineTap it
Next snippetTap Next snippet

Bug Hunt rules

One bug per snippet

Every snippet has exactly one line that causes the problem its description names. The other lines are correct as written. Where a bug shows up on a later line than the one that causes it, the line that counts is the cause: the one you would change to fix it.

Some bugs crash, like a KeyError in Python. Most do not: they quietly give the wrong answer, which is what makes them worth learning to spot.

Languages

JavaScript snippets run in a browser or Node.js. Python snippets are Python 3. SQL snippets use standard SQL; where a database behaves differently, the snippet says which one it means.

Scoring and records

Each bug you find scores one point, out of 8. There is no clock. A round never repeats a snippet. Your best score and the number of rounds played for each language choice are saved in this browser on this device.

Tips and strategy

  • Read the goal first, then ask what input would break the code. Empty lists, zero, NULL and the last item of a loop are where most bugs live.
  • Check every comparison: < or <=, == or ===, = NULL or IS NULL.
  • Watch for values that are shared when they look copied: default arguments in Python, nested arrays in a JavaScript spread, a list multiplied in Python.
  • Remember what returns what. Python’s list.sort() returns None; JavaScript’s sort() sorts as text unless you pass a compare function.
  • In SQL, think about rows that have NULLs. They are where WHERE, NOT IN and COUNT surprise people.

Frequently asked questions

Is Bug Hunt good practice for coding interviews?
It helps with the reading side of them. Interviewers often ask you to review or debug code, and spotting common mistakes quickly is the same skill. It is not a substitute for writing code yourself.
Why is the bug on that line and not where the error appears?
A bug is counted on the line you would change to fix it. That is often earlier than the line where things visibly go wrong, and learning to trace back to it is the point of debugging.
Do I need to know all three languages?
No. Choose just the language you use. The bugs in each are ones that people working in that language really make.

Guides and tips

Common coding bugs and how to spot them

Off-by-one loops, NaN and NULL, falsy zero, shared defaults, sorting surprises and forgotten awaits: what goes wrong and the habit that catches each one.

4 min read

Regex Runner

Write a regular expression that matches every string on one list and none on the other. 24 puzzles, from anchors to lookarounds.

  • Keyboard
  • Touch

Code Typer

A typing test for programmers: type real JavaScript, Python, Rust and SQL code against the clock.

  • Keyboard
  • Touch

Git Tangle

Learn git branching by doing it: type real git commands until your commit graph matches the goal. 12 levels, from commit to rebase.

  • Keyboard
  • Touch

All games