If / else if / else isNan not defined/deleted isEven?


#1


https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/2?curriculum_id=506324b3a7dffd00020bf661#


isNan is not defined
It looks like you have a ReferenceError! Maybe you deleted isEven?


I can't see it. I have even checked against some others' answers...???


var isEven = function(number) {
  if (number % 2 === 0 ) {
      return true;}
  
 else if (isNan(number)) 
 { return "That ain't a number";
 }
  else {
      return false;
  }
  
};


#2

Hi @rogue2601

Please see the code sample below.
In short IsNaN is a case sensitive method, otherwise great job :slight_smile:

var isEven = function(number) 
{
    if (number % 2 === 0 ) 
    {
        return true;      
    }  
    else if (isNaN(number)) //Case sensitive
    { 
        return "That ain't a number";
    }
    else 
    {
        return false;
    }
};

isEven(5);
isEven(6);
isEven("A");

#3

Lols, Oh my. That worked great!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.