Basic JavaScript Question:
Download Job Interview Questions and Answers PDF
How to test for bad numbers using JavaScript?
Answer:
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.");
}
var temperature = parseFloat(myTemperatureWidget.value);
if(!isNaN(temperature)) {
alert("Please enter a valid temperature.");
}
Download JavaScript Interview Questions And Answers
PDF
Previous Question | Next Question |
How to convert numbers to strings using JavaScript? | What's Math Constants and Functions using JavaScript? |