9.1 Getting an error - am I missing something?


#1

Instructions

Write an if / else statement inside the isEven function. It should return true; if the number it receives is evenly divisible by 2. Otherwise (else), it should return false;.

Make sure to return - don't use console.log()!

Code

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

Error Message

Oops, try again. Looks like your function returns false when number = 3. Check whether your code inside the if/else statement correctly returns true if the number it receives is odd.

Am I missing something? The instructions want me to check that the number is even/divisible by 2. However, when they use an odd number, they return a false and somehow that gives me an error?


#2

Hi you should remove the " " around true and false


#3

Perfect, that worked. The type of error message I got was throwing me off. Thank you!