0

Can someone pls explain how this code works ?

let i = 0; while (i <= 10) { if (i % 2 === 0) { i++; continue; } console.log(i); i++; } Mainly if (i % 2 === 0) this line!!

17th Feb 2020, 3:38 PM
R. Krishna
3 Answers
+ 1
% is modulus, i % 2 is remainder when being divided by 2. If remainder is 0, means that it is an even number.
17th Feb 2020, 3:43 PM
Gordon
Gordon - avatar
+ 1
% is called modulus operator it gives you remainder
17th Feb 2020, 3:49 PM
Mukul Singh Bhist
Mukul Singh Bhist - avatar
- 1
Please Guys It's Urgent!!
17th Feb 2020, 3:39 PM
R. Krishna