Show the sum of 12 and 8.
Acceptance criteria
- 1.#out should show 20.
JavaScript Tutorial · JavaScript Basics
These 10 tasks go with the JavaScript Operators 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 operators are symbols used to perform operations on values and variables.” .
1.Add two numbersexercise · easy · 10 min
Show the sum of 12 and 8.
Passes when: #out should show 20.
2.Find a remainderexercise · easy · 10 min · practice plan
Show the remainder of 17 divided by 5.
Passes when: #out should show 2.
3.Use exponentiationexercise · easy · 10 min · practice plan
Show 2 raised to the power of 5.
Passes when: #out should show 32.
4.Compare two values strictlyexercise · easy · 10 min · practice plan
Show whether 10 is strictly equal to the string "10".
Passes when: #out should show false.
5.Respect operator precedenceexercise · medium · 10 min · practice plan
Show the result of 2 plus 3, multiplied by 4.
Passes when: #out should show 20.
6.Fix the precedence mistakebug fix · easy · 8 min
The parentheses are missing, so the result is wrong.
Passes when: #out should show 20, not 14.
7.Fix the assignment used as a comparisonbug fix · easy · 8 min · practice plan
A single = overwrites x instead of comparing it, so this wrongly reports true.
Passes when: #out should show false, because x is 5.
8.Fix the division that should be a remainderbug fix · easy · 8 min · practice plan
This should report the remainder, not the quotient.
Passes when: #out should show 2.
9.Fix the increment placementbug fix · easy · 8 min · practice plan
Post-increment shows the old value instead of the new one.
Passes when: #out should show 6.
10.Fix the inverted comparisonbug fix · easy · 8 min · practice plan
The comparison operator points the wrong way.
Passes when: #out should show true.
Between them these tasks cover Arithmetic operators, Comparison and Operator precedence.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.