2/9 I can't figure out how to write the code


#1

Can I please have help with this.
The computer isn't logging what I want it to.
Here is my code:
var isEven = function(number) {
// Your code goes here!
if(number %2===0){
return true
}else if
isNaN === true {
return "this is not a number"
}
else{
return false
}
}

When I run this the computer says there is a problem with my syntax.
If someone could help me it would be great.
Thanks!


#2

In your isNaN, isNaN stands for Not a Number. So, to make isNaN into true, you must not put a number. Put it like this:

else if(isNaN(number))

Hope it helped! :smiley:


#3

1-st You need to check your number for isNaN like:
if(isNaN(number))
{
return "this is not a number";
}
else if(number%2===0)
{
return true;
}

else
{ 
    return false;
}

}