# Mistake in Modulo Exercise

#1

There is an error in this exercise. You are supposed to be using modulo in an if statement like this:

``````if( modulo comparison here ) {
console.log("The first number is even");
} else {
console.log("The first number is odd");
}``````

and your statement is supposed to evaluate to TRUE. I used: `10 % 2`

and it evaluated to FALSE, printing out "The first number is odd". O_o

Then I counter-checked with: `11 % 2`, which it evaluated as TRUE, printing out "The first number is even".

I've taken some JS before, and I'm pretty dead certain that those results are flip-flopped. I hope I'm not missing something super obvious. . . xD

Should this be reported to a codecademy official, or is it most likely some client-side error?

#2

if the remainder equals zero after dividing the number by 2, the number is even. In your case, the equals zero is missing

longer answer, in the end, it matters if the condition is true or false, it doesn't have to be a comparison, for example:

``````if(true){
console.log("true is true, no surprise there")
}``````

as mtf explained, zero is false and one is true, that is why it appears to be flipped. This can be useful as shortcut, but you will need to understand it

#3

The value `0` casts to `false` and any other number will cast to `true`

``````10 % 2  is 0

11 % 2 is 1``````

#4

Thank you for your really quick replies, stetim94 and mtf! That makes perfect sense. I feel put in my proper place now. . .

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.