More control flow in java script lesson 2


#1

This is my code I don't know why it isn't working

var isEven = function(number) {

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

isEven(10);


#2

i would first check if the input is a number (isNaN), so "switch" your if and else if statement


#3

Of course @stetim94 is correct that it would improve your function if you check for not a number first as it makes much more sense. But from what I can see this should already be working, did you try to refresh the page? What kind of error message do you get?


#4

put your true and false value into a pair of " ( ) "


#5

not necessary return is a keyword not a function call.