"Oops, try again. Your function returns false for 2!"


Hi, I keep getting this error for my following code. Do you know what's wrong? The error message that 2%2 === 0 is wrong makes no sense to me.

var isEven = function(number) {
if (number%2===0) {
return true;
else if (isEven=isNaN){
return "Please enter a number";
return false;



Hey there! Most of your function and if statement is correct. First of all, you don't need an else if statement! It is only asking you for if and else. Also when you call your function, it says "sup". But you forgot to close it by putting a ';'! so instead of isEven("sup") you need to put isEven("sup"); with a semicolon. Hope this helped!


@xxrazersharpzxx There are two exercises that look pretty similar and the second on requires an else if. But you're right one should add a semicolon after the function call.

@sdickers The problem with your code is this line:

else if (isEven=isNaN){

What you should do here is to check if number is really a number which would be done by isNaN(number). But what you do here is reassigning the variable that holds your function with a new value. Which is in this case the isNaN function so now isEven is just an alias for isNaN. So when the test function runs isEven(2) it really runs isNaN(2) which is obviously false as 2 is a number.


You all were right! So simple. For the error message, it seemed like something much more complicated was happening.


Yeah I know, I just remembered right after i had posted.
Anyways, no problem!