var start=prompt("What is the starting temperature?", "-40");
start=parseInt(start);
if(start == NaN) {
alert("Input was invalid. Enter a new value.");
}
var end=prompt("What is the ending temperature?", "40");
end=parseInt(end);
if(end == NaN) {
alert("Input was invalid. Enter a new value.");
}
如果输入的值为NaN,我试图让parseInt显示警告。我在一个介绍课程中,教科书没有提供很多关于如何组合这两个函数的例子。