If/else if/else unexpected token


#1

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

I am currently receiving a SyntaxError: Invalid or unexpected token. In the example, isNaN is highlighted in orange, however once entered in the code, isNaN is highlighted red. Is this the cause of the error?

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

#2

The problem is your elif statement as you assumed.

Here you are supposed to be checking if the number argument is true nit the function itself. :slight_smile:

S you'd write it like,

else if (isNaN(number) === true)


#3

help me out


#4

your elsif should check for true not false. :grin:


#5

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