gpt4 book ai didi

Javascript意外的意外标识符

转载 作者:行者123 更新时间:2023-12-02 19:16:18 25 4
gpt4 key购买 nike

出于某种奇怪的原因,这行代码被识别为

该特定行是

  `Unexpected identifier` 

bmr = 66 + ( 6.23 * weightInlbs ) + ( 12.7 heightInInches ) - ( 6.8 * age );

这是完整的代码

function metricComputation() {
var age = document.getElementById("age");
var weightInlbs = document.getElementById("weight");
var heightInInches = feetToInches(new Number(document.getElementById("heightinFt")) , document.getElementById("heightinIn"));
var bmr;
var gender = document.getElementById("gender");


if(gender === "male"){
bmr = 66 + ( 6.23 * weightInlbs ) + ( 12.7 heightInInches ) - ( 6.8 * age );
}

}

这就是整个标记

<!DOCTYPE>
<html>
<head>
<script src="bmrcalc.js"></script>
</head>
<body>
<center>
<h1>Basal Metabolic Rate</h1>
Height: <input type = "text" id ="heightinFt"> ft <input type = "text" id = "heightinIn"> in <br>
Weight: <input type = "text" id ="weight">lbs<br>
Age: <input type = "text" id = "age"><br>
Gender:<select id = "gender">
<option value = "male">Male</option>
<option value = "female">Female</option>
<select> <br>
<button onclick = "metricComputation()">Compute</button>
<div id = "result"></div>
</center>
</body>
</html>

最佳答案

你的意思是乘法吗?

bmr =  66 + ( 6.23 * weightInlbs ) + ( 12.7 * heightInInches ) - ( 6.8 * age );
// -----------------------------------------/\

关于Javascript意外的意外标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13101076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com