Skip to content

Maths with numbers

Read · 1 of 6

Division keeps the decimals

+ - * / work as in maths, and / always keeps decimals: 17 / 5 is 3.4. For whole-number division use Math.floor(17 / 5), which is 3.

% gives the remainder: 17 % 5 is 2. It checks for even numbers (n % 2 === 0) and pulls off digits (n % 10 is the last one).