Oops, try again. Your function returns true for 3!


#1



What is wrong?


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


#2

It usually makes sense for a function to always return the same type, but I believe that in this case you're meant to return boolean values when the argument is a number.
You should probably also check if it's a number before doing arithmetic operations on it. You could rely on %'s behaviour to determine if it's a number or not, but then you shouldn't also be using isNaN


#3

You're also missing the semicolons at the end of your return statements.


#4

I believe I saw somewhere, if either operand is NaN the result is NaN.

This is what I did:
var isEven = function(number) {
// Your code goes here!
if (number % 2 == 0) {
return(true);
} else {
return(false);
};
}
returns true


#5

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