JS-021
Remainder % explained in a JavaScript learning illustration — Leftover after division
Beginner3 min~3 min read#remainder#modulo#operators

Remainder %

Leftover after division

Goal

Understand how the remainder operator % works.

Explanation

  • The % operator returns the remainder after division.
  • It shows what is left after a number is split into equal parts.
  • If there is no remainder, the result is 0.
  • The % operator is often used to check whether a number is even or odd.
  • It is one of the most useful math operators.

Analogy

Imagine packing 7 apples into boxes of 2. After three full boxes, one apple is left over. That is what the % operator returns.

Code

console.log(7 % 2);
console.log(10 % 2);
console.log(9 % 2);

Result: 1 0 1

Common mistake

Many people think % means percent. In JavaScript, it is the remainder operator after division.

Remember

  • % returns the remainder.
  • If there is no remainder, the result is 0.
  • % is often used to check even or odd numbers.

Quick Quiz

What does 10 % 2 return?

Resources