+ 1
How to use % modulus operator in JavaScript?
JavaScript
3 Respuestas
+ 4
The same way you use division: it has the same precedence as division, but it returns the remainder of the division. It works with floats, not only integers, so 2.4 % 2 returns 0.4
0
the modulus is the remainder of 2 numbers divided.
4 ÷ 21 = 5...the remainder of 1 is the modulus.
often used to find odd or even numbers. odds will always have a modulos while evens will never have a modulous when divided by 2.
example 10 ÷ 2 = 5. even..no modulus
11 ÷ 2 = 5 with 1 remaining. odd..it has a modulus
0
% in JS is devision reminder!