2. if / else if / else. Function keeps returning true for 3


// Here's my code. It returned true as 3 on a previous exercise, so I fixed it to number%2===0 and it worked. But now it's doing it again. I tried refreshing and it still does it. Yerrrrg!

var isEven = function(number) {
  if (number%2===0) {
      return "true";
  } else if (isNaN(number)) {
      return "That's not a number, you idiot.";
  } else {
      return "false";



You need to use booleans true and false not strings "true" and "false". The problem is that strings in conditions are treated as true (except for the empty "") so both "true" and "false" are true when used in

    sry you failed;


1,3k views and no Heart for your help!
I will do that now :slight_smile:


I have coded like this:

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


Any number but zero evaluates to true.