Number Expressions
Numbers
π¨βπΌ Numbers are essential for any kind of calculation. Let's explore arithmetic
in JavaScript.
JavaScript supports all the standard math operators:
+addition-subtraction*multiplication/division
console.log(10 + 5) // 15
console.log(10 - 3) // 7
console.log(4 * 3) // 12
console.log(20 / 4) // 5
π There are many more operators in JavaScript beyond these basics! You can find
a complete list in the
MDN Expressions and Operators guide.
π¨ Open
and complete the following tasks:
- Log the result of adding
25and17 - Log the result of multiplying
8by6 - Log the result of dividing
100by4 - Log the result of adding
10and5, then multiplying that sum by2(group the addition so it happens first)
Completion criteria
Your output should include these numeric results (each on its own line is fine):
42(from 25 + 17)48(from 8 Γ 6)25(from 100 Γ· 4)30(from (10 + 5) Γ 2)
π° You can use parentheses to control the order of operations, just like in
regular math!