Need Help: If Else/If Else


#1



https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/0/2?curriculum_id=506324b3a7dffd00020bf661#


It is giving me: SyntaxError: Unexpected token else
How do I fix it?


var isEven = function(number) {
  // Your code goes here!
  if (number % 2 === 0) {
  return true;
  }
  
  else{
    return false;
  }
  else if (isNaN(number); => true) {
    return "It is true"
}
  else {
    return "It is false"
}

};


#2

You don't need this part.


#3

else if (isNaN(number); => true) {
Remove the semicolon here. Semicolons don't belong in if/else statements... ever. Also, true is a boolean. It cannot evaluate to greater than or equal to. Try a double equals sign instead of =>


#4

Between your if and else that evaluate true or false write your else if like this

  else if (isNaN(number) === true) {
      return "This is not a number";

#5

Okay, I fixed that part, @bandit.
But its still giving me: SyntaxError: Unexpected token else


#6

After doing that you should be left with this indented piece of code,

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

And if I'm not mistaken should work


#7

Oh it does! Thanks for the help! xD


#8

If that was the answer you were looking for, feel free to click the solution button below my reply :slight_smile: