2. If / else if / else - Can't figure out what's wrong


#1

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


var isEven = function(number) {
  // Your code goes here!
  if(number%2===0){
        return true;
        }
  else if(isNan(number)){
      return "Error: Not A Number";
    }
  else{
      return false;
  }
};

isEven(6);. 


Returns:
ReferenceError: isNan is not defined
true

Error: 
Oops, try again. It looks like you have a ReferenceError! Maybe you deleted isEven?


#2

isNan != isNaN. Capitalize the last n in it. :slight_smile:

Also, I don't know if it's just an error with pasting, but that period at the end will throw an error.


#3

Yeah, it's the post that added the period. Thank you so much! It was the capitalization in NaN I feel so silly! I have been looking at this ■■■■ code for 3 straight days!


#4

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