JavaScript Numbers — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Numbers 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
Add two numbers
easy10 minReport the sum of ten and three.
- 2
Find a remainder
easy10 minReport the remainder when ten is divided by three.
- 3
Test for an even number
easy10 minReport whether four is even.
- 4
Raise to a power
easy10 minReport two to the power of ten.
- 5
Divide by zero
medium10 minReport what dividing by zero gives.
Find the bug(5)
- 1
Fix the number written in quotes
easy8 minA number in quotes is a string, so plus joins it.
- 2
Fix the wrong operator for even
easy8 minDivide gives a fraction; the remainder is what is wanted.
- 3
Fix multiply used for a power
easy8 minTwo times ten is not two to the power of ten.
- 4
Fix the division expected to throw
easy8 minDividing by zero gives Infinity rather than an error.
- 5
Fix the separator treated as a decimal
easy8 minUnderscores group digits; a comma does not work in a number.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace