2/9 error


#1

Continuing the discussion from 2/9 - error ....returns false:



 var isEven = function(number) 
 {
       // Your code goes here!
       if(number%2 === 0)
       {
            return "The number is Even Number"; 
       }
      else if(isNaN(number))
      {
           return "not a number"; 
      }
      else
      {
           return "The number is Odd Number"; 
      }
 };
 isEven(55);

my code, actually it should work, but it is showing the below error..
Oops, try again.
Your function returns true for 3!....
can any one please help me to solve it..


#2

Can you please indent your code


#3

And your else if(isNan(number)) should be
else if (isNaN(number) === true) instead


#4

Your also supposed to be returning booleans i.e(true; false;)


#5

I replaced else if(isNan(number)) with else if (isNaN(number) === true)....but it is showing same error......


#6

Have you changed your return statements from strings to booleans


#7

Your else if statement is fine just your if and else statement's return's need to be true and false not strings


#8

It's working. Thank you so much....


#9

You're welcome. :+1:


#10

But doesn't that do the same thing? If it isn't a number, isNaN is automatically seen as true...


#11

No specifying it makes a big difference .:slight_smile: