0

I don't understand how to use the" %" in JavaScript

I need help with the"%" in java

30th Aug 2019, 12:53 AM
Kpogli Freeman
Kpogli Freeman - avatar
3 ответов
+ 1
% is an arithmetic operator in most if not all programming languages It will give you the remainder of two numbers e.g. 5%2=1 2 can go into 5 twice remainder 1 Try this simple code for(let i=0;i<100;i++){ if(i%2==0) console.log(i) } what do you think will happen?
30th Aug 2019, 1:00 AM
Logomonic Learning
Logomonic Learning - avatar
+ 1
% is a modulus sign it means remainder Example 10 % 2 Means what remains after diving 10 by 2 which is 0 I. E 10 % 2 = 0
30th Aug 2019, 5:39 AM
Qudusayo
Qudusayo - avatar
+ 1
I now understand. Thank you very much
30th Aug 2019, 7:33 AM
Kpogli Freeman
Kpogli Freeman - avatar