Basic JavaScript Question:
Download Questions PDF

How to test for bad numbers using JavaScript?


The global method, "isNaN()" can tell us about value if a number has gone bad in JavaScript.

var temperature = parseFloat(myTemperatureWidget.value);

if(!isNaN(temperature)) {
alert("Please enter a valid temperature.");

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
How to convert numbers to strings using JavaScript? What's Math Constants and Functions using JavaScript?