Exercise 2 - if else and using isNaN


Hi all,
I'm not clear how to use the isNaN function to write the expression within my code. I've tried different variations but my syntax is unsuccessful.

Any helpful explanations would be appreciated. My code is below.

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



You are using a semi-colon-; at the end of your IF-condition
else if(isNaN (number));
For the Javascript-Interpreter the semi-colon-; is seen as an End-of-Statement indicator

  • the IF-statement is ended, and the code-block { return "it's not a number"; } is NOT run
  • the Javascript Interpreter is NOT expecting an ELSE-statement and throws an Error

Remove the semi-colon-;

[ quote]
The point is that even if-else must end with ; if it is following by a single statement, like
if (condition) statement;

The reason that if-else does NOT end with a semi-colon-;
when express {group of statement }
because a semi-colon-;
is NOT a symbol for ending {group of statement },
but IS a symbol to end a single statement.



Thanks for your help Leonhard, I can see where I went wrong. :slightly_smiling: