isNaN is killing me


#1


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

Oops, try again. Make sure your if/else if/else statement returns a string when the function input isn't a number.


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


#2

Passes on my end. Maybe you did something with the environment that breaks your function or the submission test. Refresh page.

However, you should probably check if the value is a number before treating it like a number.


#3

Well then, I have no idea what the problem was... but refreshing the page worked. Thanks!!


#4

A post was split to a new topic: What is wrong with this?


#5

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