JavaScript Statements — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Statements 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
Run statements in order
easy10 minSet a value, change it, then show the final one.
- 2
Write a declaration statement
easy10 minDeclare a constant and display it.
- 3
Use a conditional statement
easy10 minShow "branching" when a flag is true.
- 4
Use a loop statement
easy10 minLoop three times and report "looped".
- 5
Combine several statements
medium10 minDeclare, calculate and display in three statements.
Find the bug(5)
- 1
Fix the statements in the wrong order
easy8 minThe value is displayed before it is updated.
- 2
Fix the statement inside the wrong block
easy8 minThe display line only runs when the flag is false.
- 3
Fix the incomplete statement
easy8 minThe assignment has no value on the right.
- 4
Fix the loop count
easy8 minThe loop runs the wrong number of times.
- 5
Fix the wrong operator in the calculation
easy8 minAdding instead of multiplying gives the wrong total.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace