0
I don't understand how to use the" %" in JavaScript
I need help with the"%" in java
3 Risposte
+ 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?
+ 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
+ 1
I now understand. Thank you very much