If/else if/else help


I need help on this lesson. I don't know how to put the else if statement in my code. Am I doing it correctly? (And what about isNaN? Am I using that correctly?)


The console says: SyntaxError: expected expression, got keyword 'else'

and the error message it gives me is: "Oops, try again. There was a problem with your syntax."

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

What am I doing wrong? This is honestly very confusing to me. Any help would be appreciated. Thanks :slight_smile:


you can't have a else if after an else, the order is:

else if
/* more else if if you want */

you can't have else after else if, since else is everything else, there is nothing after it


Else is like default, and it goes down the list of else if to test all of it's options. It's like a list, and once it fits a category, (else), it will not continue to look for it's condition to agree with another statement.


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