我是编程新手,无法弄清楚我正在处理的这段代码有什么问题。在开发者控制台中,我一直收到这些错误代码。控制台错误含义?
Hw%20multifuncion.html:24
未捕获SyntaxError
:意外令牌非法 Hw的multifuncion.html
:34未捕获ReferenceError
:计算没有定义
这分别意味着什么?我不熟悉调试器,所以任何帮助将不胜感激。
<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>WindChill</title>
<script type="text/javascript">
/* Input: Temperature in fahrenheit and windspeed in mph
* Processing: Calculate windchill and output to user. While useing two funcions, and assign a call and return.
* Output: The windchill
*/
function compute() {
var temperature = document.getElementById("temperature").value;
var windspeed = document.getElementById("windspeed").value;
var temp = parseInt(temperature);
var wind = parseInt(windspeed);
var result = windChill(temp, wind);
document.getElementById("output").innerHTML = result;
}
function windChill(tempF, speed) {
var f = 35.74 + 0.6215 * tempF− 35.75 * Math.pow(speed, 0.16) + 0.4275 * Math.pow(tempF, 0.16);
}
</script>
</head>
<body>
Temperature (Fahrenheit)
<input type="text" id="temperature" size="5">
<br>Wind speed (MPH)
<input type="text" id="windspeed" size="5">
<button type="button" onclick="compute()">WindChill</button>
<div id="output"></div>
</body>
</html>
你有一个'-'而不是'-'符号。请求前使用[JSHint](http://jshint.com/)。 – Xufox
你也需要在函数windChill()中返回f;'' – linktoahref
有时候错误可能是神秘的,在你的情况下,它们不是。语法错误不是减号,并且当脚本出错时,没有'compute()'函数,并且一旦修复,函数需要返回一些东西 – adeneo