Skip to content
Justice Tech School

Exponent, Modulo and Integer Division

** raises to a power and % gives the remainder. JavaScript has no integer division, so use Math.floor, Math.trunc or | 0 on positive numbers.

Example
console.log(2 ** 10, 17 % 5, -7 % 3);
console.log(Math.floor(17 / 5), Math.trunc(-7 / 2));
console.log(10 % 2 === 0 ? "even" : "odd");

Exercise

Remainder.

17  5

Quiz Test

What does 17 % 5 give?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.