isNaN


#1

I'm getting the error msg. unexpected token var when I add the
"isNaN" function. Here is the code, with a call of the string "oooo".
Can I declare the 2 functions before the loops?
Thanks.


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


#2

@mccbjnn,

1

Remove the code-line
var isNaN = function(number)

2

change your ELSE-IF condition isNaN(number)=true
into
isNaN(number) === true

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

3

and then reset your Browser
++++ reset of session *****************
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#3

Thanks. A question though. When we use true and false like this, aren't they boolean and hence don't need the ===?