[SOLVED] Pulling out my hair! IT IS A NUMBER!

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

[SOLVED] Pulling out my hair! IT IS A NUMBER!

Post by patch2112 »

Hello all (stressed and non-stressed alike)

Here is code...

Code: Select all

function get_code_value()
{
var ei=1+1;

if (!isNaN(ei))
{ alert ("ei IS NOT a number"); }

if (isNaN(ei))
{ alert ("ei IS a number"); }

alert (ei);
}
The first alert I get says "ei IS NOT a number"
The second alert says "2".

How can I be getting "IS NOT a number" and yet get the 2 instead of 11?

Thanks,
Philip
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

isNaN tests if value is NaN (Not a Number) you are testing if the value is Not Not A Number

The first google on isNaN was: http://msdn.microsoft.com/library/en-us ... hisnan.asp
patch2112
Forum Commoner
Posts: 86
Joined: Sun Oct 31, 2004 9:44 am
Location: London

Sry

Post by patch2112 »

I'd like to formally apologize for being an idiot. Long Weekend.

Thanks,
Philip
Post Reply