isEven function returning true when the input is 3?


#1

My code is

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

I don't understand why it isn't working as it's supposed to.


#2

Hi you dont need to put isNaN(number) === false just put

isNaN(number)

#3

What wiz said:

else if (isNaN(number)) {
return ".....";
}

to check put isEven(any number); below this last bracket "};"


#5

i got the same problem

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

#6

Hi, all! I had the same problem. Could you help me, please?


#7

Now, it is working!


#8

var number;

var isEven = function(number) {
// Your code goes here!

if (number%2=== 0){
return true;
}
else
{

  return false;

}
};
isEven(2);