+ 4
How to use the isNaN function in javaScript.
Take a look at this code. var theNumber = prompt ("Pick a number", ""); if (! isNaN (theNumber)) { alert ("Your number is the square root of " + theNumber * theNumber ); How does "isNaN" and "! isNaN" work?
1 Answer
+ 1
isNaN() checks whether the given value/variable is a legal number or not i.e. is a number or not . It converts the provided value to number first then checks whether it's a number or not and returns true if the value is not a number else returns false.