More on Control Flow #1 if/else


#1

var isEven = function(number) {
// Your code goes here!
if(isEven % 2 === 0){
return true;
} else {
return false;
}
}

Looks like your function returns false when number = 2. Check whether your code inside the if/else statement correctly returns true if the number it receives is even.

I thought to find an even number we use % and if there is 0 remainder then it is even/true. I also know that 0 is false and 1 is true. So why am I getting this error and how do I get around this? Is (isEven % 2 === 0) true or not?


#2

It should be (number%2 ===0) and NOT (isEven%2===0)
The reason is because we are checking whether the passed in number is divisible by two.

You are also missing a semi colon at the end of your function. Remember, using that way to declare a function requires a semicolon at the end.


#5