JavaScript Debugging — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Debugging lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Check the types
easy10 minReport the types of a string and a number.
- 2
Spot the type mismatch
easy10 minReport whether the two values are strictly equal.
- 3
Label what you print
easy10 minBuild a labelled report of the width and area.
- 4
Narrow down a pipeline
easy10 minReport the value after each stage of the transformation.
- 5
Find the wrong assumption
medium10 minConvert the value before adding, and report the total.
Find the bug(5)
- 1
Fix the values compared without checking types
easy8 minThe two look identical when printed but are different types.
- 2
Fix the unlabelled output
easy8 minBare values give no clue which is which.
- 3
Fix the silent joining bug
easy8 minThe price is text, so plus joins instead of adding.
- 4
Fix the wrong filter boundary
easy8 minThe pipeline keeps the wrong values, which printing each stage reveals.
- 5
Fix the type read from the value
easy8 minPrinting the value alone does not reveal its type.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace