Help for number 2


var isEven = function(number) {
    if (number % 2 === 0)
        return true;
    else if (isNan(number))
        return false;
        return false;


I don't get what is wrong with the code above.
It seems that there is an unexpected token "else".
Thanks for all your help


That's as good a clue as any. Take a look at your code, specifically paying attention to lines involving your else ifs and elses. Check spelling, grammar and syntax.


A slight mistype, perhaps. No doubt, you meant to write, isNaN(number)?


NaN is a peculiar object.

 > isNaN(NaN)
=> true
 > typeof NaN
=> 'number'

That is why the isNaN() method was created, to remove all ambiguity.

Don't worry about using NaN in your code. We never use it. Like undefined it is something that JS handles internally.


yes, I completely missed that

Thank You


Also I think that I forgot a "{" after the "(isNan(number))"


Good catch! I knew you would find it. Now you know why we preach about braces having their own line (at least closing braces, anyway).


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