-4

confused what "0" and "1" is doing behind the scene.

if(13 % 2 !== 0) {

alert ("Your age is odd!"); }

and

if(13% 2 !== 1) {

alert (""); }

  • @void That is not a good duplicate as it is not really about the modulo operator. [What does % do in JavaScript?](https://stackoverflow.com/questions/8900652/what-does-do-in-javascript) is more appropriate. – str Mar 04 '18 at 10:34
  • @str added the duplicate. – void Mar 04 '18 at 10:35
  • While this may or may not be a duplicate, it is not clear what the actual question is. Are you confused about what `!==` does? Are you confused what the `%` does? Or are you confused what a `0` or `1` is? We can't read your mind. Please [ask a question](https://stackoverflow.com/help/how-to-ask) that **can be answered**. – NightOwl888 Mar 05 '18 at 00:54

1 Answers1

0

value % 2 will give if the rest of a division by 2, with even numbers this is zero.

for ex. 4 / 2 = 2 rest 0 5 / 2 = 2 rest 1

so if the age is > 5 this both will work ok. But with = 5 and similar ages with a rest of 1 this should fail.

Mark1104
  • 11
  • 3