Show whether 3 * 7 equals 21.
Acceptance criteria
- 1.#out should show correct.
JavaScript Tutorial · JavaScript Statement & Expression
These 10 tasks go with the JavaScript Expressions 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: “A JavaScript expression is a piece of code that produces a value.” .
1.Evaluate an arithmetic expressionexercise · easy · 10 min
Show whether 3 * 7 equals 21.
Passes when: #out should show correct.
2.Evaluate a string expressionexercise · easy · 10 min · practice plan
Join "code" and "base" and confirm the result.
Passes when: #out should show codebase.
3.Use a comparison expressionexercise · easy · 10 min · practice plan
Show whether 8 is greater than 3.
Passes when: #out should show true.
4.Use a ternary expressionexercise · easy · 10 min · practice plan
Show "even" or "odd" for the number 10.
Passes when: #out should show even.
5.Combine expressionsexercise · medium · 10 min · practice plan
Confirm that (2 + 3) * 2 equals ten.
Passes when: #out should show ten.
6.Fix the precedence in the expressionbug fix · easy · 8 min
Missing parentheses change the result.
Passes when: #out should show ten.
7.Fix the assignment used as an expressionbug fix · easy · 8 min · practice plan
A single = assigns rather than compares.
Passes when: #out should show wrong.
8.Fix the reversed ternarybug fix · easy · 8 min · practice plan
The two outcomes are swapped.
Passes when: #out should show even.
9.Fix the comparison directionbug fix · easy · 8 min · practice plan
The comparison points the wrong way.
Passes when: #out should show true.
10.Fix the numeric string joinbug fix · easy · 8 min · practice plan
The values are joined as text instead of added.
Passes when: #out should show correct.
Between them these tasks cover Expressions vs statements and Evaluation.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.