Control Flow - "if / else if / else" using isNan


#1

Hi all,

I'm getting the following error when I submit this code: SyntaxError: expected expression, got keyword 'else'

I'm slightly pulling my hair out because I can't see what's wrong. Can anyone else see what's missing? This is the code I'm running:

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

  
    else {
        return false;
    };
};

isEven("Hello");

Thanks!


#2

...And I literally just worked it out! I removed semi-colons after each if / else if statement. Doh!


#3

The problem is not about missing but about having too much :slightly_smiling: in this case semicolons in your conditional structure. Have a look at this for a longer explanation:


#4

Yep, all sorted now. Thanks for your prompt help!