How can I use modulo operator (%) in JavaScript?

Ziyaddin Sadigov picture Ziyaddin Sadigov · May 12, 2013 · Viewed 330.2k times · Source

How can I use modulo operator (%) in calculation of numbers for JavaScript projects?

Answer

MarioDS picture MarioDS · May 12, 2013

It's the remainder operator and is used to get the remainder after integer division. Lots of languages have it. For example:

10 % 3 // = 1 ; because 3 * 3 gets you 9, and 10 - 9 is 1.

Apparently it is not the same as the modulo operator entirely.