2. If/else If/else


#1

Error: Oops, try again. Your function returns true for 3!

Tried both === and less strict == on If statement, can't figure it out.

var isEven = function (number) {
    if (number % 2 === 0) {
        return true;
    } else if (isNaN('number')) {
        return "This isn't a number!";
    } else {
        return false;
    }
};


#2

the problem is in this line:

else if (isNaN('number'))

the string 'number' is indeed not a number. Which means else if will run, if else if runs, else will never run.

you want to check if the variable (function parameter) number is a number, remove the ' around number


#3

Just like magic. Thank you for the explanation.