I don't get what I'm doing wrong (More on Control Flow in JS lesson 1)


#1

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

error message:
Oops, try again. 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.

could you help me out?


#2

You shouldn't check if the function name i s divisible by 2 but the argument number.

if (number % 2 ===0)


#3

Thank you very much man! :smile:


#4

Why is this wrong?? I keep getting, "ReferenceError. Maybe you deleted isEven?"

var isEven = function(number) {
if(number%2===0) {
return true;
}
else if(isNaN(number)=true) {
return "This is not a number.";
}
else {
return false;
}
};


#5

I didn't include the isNaN part, You hadn't learned anything about it then so I just forgot about it? Try that?