Remainder Operator

noun

say it: “rih-MAYN-der OP-er-ay-ter” /rɪˈmeɪndər ˈɒpəreɪtər/

The % symbol, read "remainder" or "mod": it divides one number by another and gives back what's left over, so 14 % 6 is 2.

What is Remainder Operator in JavaScript?

Remainder Operator — %, read "remainder" (some people say "mod"). It divides one number by another and gives back what's left over, so it tells you how many muffins don't fill a whole box, or whether a number is even.

const muffins = 14;
console.log(muffins % 6);       // 2: two left after two boxes of 6
console.log(muffins % 2 === 0); // true: 14 is even

In a sentence

  • “The remainder operator told me 17 % 2 is 1, so 17 is an odd number.”

Level: Novice · More JavaScript terms at this level

Updated