JavaScript Operators — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Operators 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 minShow the sum of 12 and 8.
- 2
Find a remainder
easy10 minShow the remainder of 17 divided by 5.
- 3
Use exponentiation
easy10 minShow 2 raised to the power of 5.
- 4
Compare two values strictly
easy10 minShow whether 10 is strictly equal to the string "10".
- 5
Respect operator precedence
medium10 minShow the result of 2 plus 3, multiplied by 4.
Find the bug(5)
- 1
Fix the precedence mistake
easy8 minThe parentheses are missing, so the result is wrong.
- 2
Fix the assignment used as a comparison
easy8 minA single = overwrites x instead of comparing it, so this wrongly reports true.
- 3
Fix the division that should be a remainder
easy8 minThis should report the remainder, not the quotient.
- 4
Fix the increment placement
easy8 minPost-increment shows the old value instead of the new one.
- 5
Fix the inverted comparison
easy8 minThe comparison operator points the wrong way.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace