If/else if/else & isNan


#1

With this code, I get a way to go and the option to move on BUT I can't tell if anything is actually happening or supposed to happen? I don't see any output anywhere - should there be? Thank you in advance.


var isEven = function(number) {
if (number % 2 === 0) {
return true;
}
else if (isNaN(number)) {
return "Your input isn't a number.";
}
else
{
return false;
}

};


#2

Well you can test if your code is working by calling the function e.g.

isEven(3) --> false;

or better

console.log(isEven(42)); ---> true

And what the function should do is specified in the instructions:

  • true for even numbers as input
  • false for odd numbers as input
  • A string as explanation if the input is not a number at all

Seems to be ok, so far so just play around a bit to get used to the idea of function.