+ 1

How to work with % ? what's the rule in javascipt?

alert(60%6); = 0 How? document.write(10%6); = 4 How? How???

20th Aug 2017, 3:48 AM
ARB
ARB - avatar
2 Antworten
+ 12
Modulus (%) operator returns the division remainder (what is left over). 60 divided by 6 gives 0 as a remainder ( 6*10 = 60, 60-60 = 0 ) and 10 divided by 6 gives 4 as a remainder ( 6*1 = 6, 10-6 = 4 ). It's the basic Math in which we divide two numbers for getting a remainder :D
20th Aug 2017, 3:53 AM
Dev
Dev - avatar
0
divide 60 by 6 and returns you the remainder
20th Aug 2017, 1:43 PM
Milan Zanden
Milan Zanden - avatar