我想要如何调用函数中的函数。如何在JavaScript中调用函数中的函数
这是我的函数:
function TempConvert() {
var tempVal = prompt('Enter a temperature');
var newTemp;
newTemp = (tempVal - 32/1.8 + 273.15);
alert(newTemp);
}
这需要它被称为:
function iMenu() {
var choice = prompt("Type in a number for the corresponding option\nOption 1: Temperature Converter\nOption 2: Option 2\nOption 3: Exit");
if (choice == "1") {
// TempConverter needs to go here <<----
}
else if (choice == "2") {
alert('Option2');
}
else {
alert('Bye');
return;
}
}
感谢。我试过把它放在那里,但它没有效果。
http://eloquentjavascript.net/chapter3.html –
你能说明这些函数是如何位于整个代码中的吗?看起来像某种范围的问题,所以我们需要知道什么是什么功能。 – kmoe