Control Flow JavaScript Error Message?


#1


var isEven = function(number) {
  // Your code goes here!
  if (number%2 === 0) {
    return true;
  }
  else if (isNaN) {
    return "Please insert a real number!!"; 
  }
  else {
     return false; 
  }
};

isEven(13);

To me, the code looks fine. . . However, when I try it, codecademy gives me "Oops, try again. Your function returns true for 3!" Like what am I doing wrong????? and what does this error even mean?


#2

Sorry y'all I'm just stupid. . .

var isEven = function(number) {
  // Your code goes here!
  if (number%2 === 0) {
    return true;
  }
  else if (isNaN(number)) {
    return "Please insert a real number!!"; 
  }
  else {
     return false; 
  }
};

isEven(13);

Works fine. . . forgot to put (number) after isNaN, because otherwise the computer wouldn't know what I was trying to test isNaN on. . . Wow, I can't believe that I couldn't figure that out before rushing to post it on here. . .


#3

Your post is beautiful!


#4

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