JavaScript Arithmetic Operators
Arithmetic operators do math with numbers.
You already know most of these from school.
Think of a toy cash register. Plus and minus move the total.
Add and subtract
Multiply and divide
Remainder
Exponent
Plus plus and minus minus
Addition and subtraction
+ adds. - subtracts.
Multiplication and division
* multiplies. / divides.
Division can give a decimal.
Remainder
% gives what is left after dividing.
Think of sharing 10 cookies with 3 friends. Each gets 3. One cookie is left.
Exponent
** means raised to a power.
2 ** 3 means 2 times 2 times 2.
Increment and decrement
++ adds one. -- subtracts one.
These are handy counters in games and loops.
Order of work
JavaScript follows math order.
Multiply and divide happen before add and subtract, unless parentheses say otherwise.
Tip: Use parentheses when the order might confuse a reader. Clear beats clever.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.