Modulus division Flashcards

1
Q

modulus operator (%)

A

The modulus operation finds the remainder of division of one number by another. In other words, 10 modulus 5 is 0
because five goes into ten twice with no remainder; while 11 modulus 5 is 1 because five goes into ten twice with a
remainder of 1.
JavaScript, like many other languages, uses the percent symbol (%) to indicate the modulus operation. It is often
used to determine whether a number is an even or odd number or whether it is a multiple of a certain number.

10 % 5

if (num % 5 == 0)
{

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly