I am stuck on If / else if / else of More on Control Flow in JS and I don't know what i'm doing wrong


#1

Here's my code:

var isEven = function(number) {
if(number % 2){
return false;
}else if(isNaN(number) => true){
return "thars not a number";
}else{
return true;
}

};

Here's the error i'm getting:

SyntaxError: Unexpected token (

Anyone able to help me?


#2

Hi here if(number % 2) you should put It equale to 0 like that

if(number % 2 === 0)

And then here else if(isNaN(number) => true)
why do you use => you should use just ===


#3

I hope this will help

var isEven = function(number) {
    if(number%2===0){`
            return true;`
        } 
    else if (isNaN(number)) {
        return "The input is not a number.";
        }
    else {
        return false;
        }
};

isEven("Howdy!");


#4

@gracia17 please don't post "solutions" without details on what you changed and why. In the end they all look similar and progressing through copy and paste isn't helpful as those are more likely to end up here again for the same reasons.

@wizmarco the part about the => in true is correct. But the first part actually works number%2 will produce either 0 or not zero (for integers 1). And according to this:
http://www.sitepoint.com/javascript-truthy-falsy/
0 has a value of false and any other number is true so it does what it is supposed to do. I just hope that @chasew395 knows this and not just found it through luck :slightly_smiling: