Problem with 2/14


#1

this code doesn't work with the site it says"Your function returns true for 3" so i tried it in a actual html page and it works just fine.


#2

Hi, i'm not sure what's wrong with that code but here's what worked for me hope it helps:

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

isEven(10);

#3

Thanks, its the same code except the last line, maybe i should try that? weird but I'll do it.


#4

Your code seems to be ok could you copy and paste it so one can execute it instead of having to retype it? As said from a first view it should be ok.


#5

var isEven = function(number) {

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

return "nan";
}

else {
return false;

}
}

Right, so here is my code, thanks for the reply.


#6

Ok... As expected I can pass using your code without gettingn any error message. In this cases it often helps to refresh the page and submit it again (this really often helps as it resets the javaScript).


#7

Thanks for the help, keep up the good work i really appreciate this website.


#8

Not sure this is all right. Asking the computer to find the modulus of something before you know that it is a number.
You can stick a diagnostic in the program like: console.log(number + " Not a number");
The web site unit tests the code and it appeared that the isNan function returned true for even numbers.