JavaScript Semicolons — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Semicolons 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
End statements with semicolons
easy10 minWrite two terminated statements and show the second value.
- 2
Separate statements on one line
easy10 minTwo statements on one line need a semicolon between them.
- 3
Terminate a declaration
easy10 minDeclare a value, end the statement, then display it.
- 4
Return on the same line
easy10 minReturn a value on the same line as return to avoid ASI problems.
- 5
Terminate before a parenthesis
medium10 minA missing semicolon before a ( can join two lines — avoid it here.
Find the bug(5)
- 1
Fix the return broken by a newline
easy8 minA newline after return makes it return undefined.
- 2
Fix the missing separator
easy8 minTwo statements share a line with no semicolon between them.
- 3
Fix the comma used as a terminator
easy8 minA comma continues the declaration instead of ending it.
- 4
Fix the semicolon after if
easy8 minA semicolon straight after if() ends the statement early.
- 5
Fix the missing semicolon before a bracket
easy8 minThe next line is treated as an index of the previous value.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace