JavaScript Expressions — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Expressions 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
Evaluate an arithmetic expression
easy10 minShow whether 3 * 7 equals 21.
- 2
Evaluate a string expression
easy10 minJoin "code" and "base" and confirm the result.
- 3
Use a comparison expression
easy10 minShow whether 8 is greater than 3.
- 4
Use a ternary expression
easy10 minShow "even" or "odd" for the number 10.
- 5
Combine expressions
medium10 minConfirm that (2 + 3) * 2 equals ten.
Find the bug(5)
- 1
Fix the precedence in the expression
easy8 minMissing parentheses change the result.
- 2
Fix the assignment used as an expression
easy8 minA single = assigns rather than compares.
- 3
Fix the reversed ternary
easy8 minThe two outcomes are swapped.
- 4
Fix the comparison direction
easy8 minThe comparison points the wrong way.
- 5
Fix the numeric string join
easy8 minThe values are joined as text instead of added.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace