Set a value, change it, then show the final one.
Acceptance criteria
- 1.#out should show second.
JavaScript Tutorial · JavaScript Statement & Expression
These 10 tasks go with the JavaScript Statements 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 statements are instructions that tell the browser what to do.” .
1.Run statements in orderexercise · easy · 10 min
Set a value, change it, then show the final one.
Passes when: #out should show second.
2.Write a declaration statementexercise · easy · 10 min · practice plan
Declare a constant and display it.
Passes when: #out should show declared.
3.Use a conditional statementexercise · easy · 10 min · practice plan
Show "branching" when a flag is true.
Passes when: #out should show branching.
4.Use a loop statementexercise · easy · 10 min · practice plan
Loop three times and report "looped".
Passes when: #out should show looped.
5.Combine several statementsexercise · medium · 10 min · practice plan
Declare, calculate and display in three statements.
Passes when: #out should show twenty.
6.Fix the statements in the wrong orderbug fix · easy · 8 min
The value is displayed before it is updated.
Passes when: #out should show second.
7.Fix the statement inside the wrong blockbug fix · easy · 8 min · practice plan
The display line only runs when the flag is false.
Passes when: #out should show branching.
8.Fix the incomplete statementbug fix · easy · 8 min · practice plan
The assignment has no value on the right.
Passes when: #out should show assigned.
9.Fix the loop countbug fix · easy · 8 min · practice plan
The loop runs the wrong number of times.
Passes when: #out should show looped.
10.Fix the wrong operator in the calculationbug fix · easy · 8 min · practice plan
Adding instead of multiplying gives the wrong total.
Passes when: #out should show twenty.
Between them these tasks cover Statement structure and Execution order.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.