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 以显示警报。我在上入门课,教科书没有给出很多如何结合这两个功能的例子。