+ 1

How to use % modulus operator in JavaScript?

JavaScript

2nd Jun 2019, 8:31 AM
Rebecca.S.Mathews
Rebecca.S.Mathews - avatar
3 Respostas
+ 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
2nd Jun 2019, 8:36 AM
Airree
Airree - avatar
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
2nd Jun 2019, 8:38 AM
Jason Kennedy
0
% in JS is devision reminder!
2nd Jun 2019, 9:57 AM
CodeFu
CodeFu - avatar