# Lesson 21 modulo & if then (fuzzy math)

#1

I got the answer right on this one and I understand the modulo concept. What is bugging me is that the lesson is calling divisibility "even"

Which is not true. 15/5=3 and has no remainder. 15 is divisible by 5, which is why this code works.

if( 15%5===0 ) {
console.log("The first number is even");
} else {
console.log("The first number is odd");
}

A number is even when it is divisible by 2 and 2 only. I find this misleading. Anyone else have a problem with that? Or am I missing something?

#2

That equation has a remainder of 0.

• a number is even if it gives a remainder of 0 when you divide it by 2
• 0 / 2 = 0
• 0 is considered even

#3

That makes a little more sense! Just thought they were asking me to execute a modulo that would result in a remainder of 0 not any even number (bc of the reference to the modulo execution in the lesson).

In actuality the code above would work with an odd remainder too as long as it evaluates to "true"

For example:
if(23%5===3) {console.log("The first number is even");
}
else {
console.log("The first number is odd");
}

Even though the number isn't even, 23%5===3 evaluates to true, so the console prints "The number is even"

Got caught up in the semantics on that one. Still I get the code, and that's good!

#4

Yes, that's good!

number % 2 === 0

That is the definition of even so it is used all the time to check whether a number is even or odd.

#5

derp derp. I somehow missed the instruction to use a modulo and an even number.

I was focusing on programming it to evaluate true.

(I def know what an even number is, haha)

Thanks for helping me through