-2
通过一个Javascript教程,并得到了这个例子,应该写一些温度转换到屏幕上。这是直接来自教程的代码,它根本不起作用。不在屏幕上打印任何内容。 如果有错误,我找不到任何错误。Javascript教程代码不起作用
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 3, Example 4</title>
</head>
<body>
<script>
var degFahren = [212, 32, -459.15];
var degCent = [];
var loopCounter;
for (loopCounter = 0; loopCounter <= 2; loopCounter++) {
degCent[loopCounter] = 5/9 * (degFahren[loopCounter] - 32);
}
for (loopCounter = 2; loopCounter >= 0; loopCounter−−) {
document.write("Value " + loopCounter +
" was " + degFahren[loopCounter] +
" degrees Fahrenheit");
document.write(" which is " + degCent[loopCounter] +
" degrees centigrade<br />");
}
</script>
</body>
</html>
你从哪儿弄来从代码?它看起来像'loopCounter - '中的破折号('--')不是破折号,而是别的。这应该工作:https://jsfiddle.net/g0ojv8y5/ – putvande
开始Javascript第5版 –
哦geez大声笑。这是相当的错误。但是,你是对的,那就是诀窍。谢谢。甚至不知道这是可能的。 –