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


#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 false;
  } else if (isNaN(number)) {
      return "Your input is not a number";
  }
  else { return true;
  }
  
};


isEven(40);


#2

Hi I don't know why but that form where the if statement check for the number that aren't even..

if (number % 2 !== 0) {
   return false;
}

only work on the first leson but in this one it wont work, so you should change the if statement so that it will check if the number is even like that

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

so in this case you should change the else statement so that it will return false


#3

A post was split to a new topic: isNaN question


#5

isNan statement must come even before we check whether the given input is odd or even


#6