Write two terminated statements and show the second value.
Acceptance criteria
- 1.#out should show terminated.
JavaScript Tutorial · JavaScript Statement & Expression
These 10 tasks go with the JavaScript Semicolons chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “JavaScript semicolons are used to separate statements.” .
1.End statements with semicolonsexercise · easy · 10 min
Write two terminated statements and show the second value.
Passes when: #out should show terminated.
2.Separate statements on one lineexercise · easy · 10 min · practice plan
Two statements on one line need a semicolon between them.
Passes when: #out should show separated.
3.Terminate a declarationexercise · easy · 10 min · practice plan
Declare a value, end the statement, then display it.
Passes when: #out should show ended.
4.Return on the same lineexercise · easy · 10 min · practice plan
Return a value on the same line as return to avoid ASI problems.
Passes when: #out should show returned.
5.Terminate before a parenthesisexercise · medium · 10 min · practice plan
A missing semicolon before a ( can join two lines — avoid it here.
Passes when: #out should show safe.
6.Fix the return broken by a newlinebug fix · easy · 8 min
A newline after return makes it return undefined.
Passes when: #out should show returned.
7.Fix the missing separatorbug fix · easy · 8 min · practice plan
Two statements share a line with no semicolon between them.
Passes when: #out should show separated.
8.Fix the comma used as a terminatorbug fix · easy · 8 min · practice plan
A comma continues the declaration instead of ending it.
Passes when: #out should show ended.
9.Fix the semicolon after ifbug fix · easy · 8 min · practice plan
A semicolon straight after if() ends the statement early.
Passes when: #out should show guarded.
10.Fix the missing semicolon before a bracketbug fix · easy · 8 min · practice plan
The next line is treated as an index of the previous value.
Passes when: #out should show safe.
Between them these tasks cover Statement termination and Automatic semicolon insertion.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.