0

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

这个特定的行是

  `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>
4

4 回答 4

2

你的意思是乘法吗?

bmr =  66 + ( 6.23 * weightInlbs ) + ( 12.7 * heightInInches ) - ( 6.8 * age );
// -----------------------------------------/\
于 2012-10-27T14:35:54.800 回答
0

这是错误:

12.7 heightInInches

标识符heightInInches不应位于此位置。预期的是像 *、+、- 或 / 这样的运算符

于 2012-10-27T14:36:31.920 回答
0
if(gender === "male"){
     bmr =  66 + ( 6.23 * weightInlbs ) + ( 12.7 * heightInInches ) - ( 6.8 * age );
}

你忘记了*( 12.7 heightInInches )

于 2012-10-27T14:36:45.603 回答
0

您在 "12.7" 和 heightInInches" 之间缺少 "*":

bmr =  66 + ( 6.23 * weightInlbs ) + ( 12.7 * heightInInches ) - ( 6.8 * age );
于 2012-10-27T14:40:09.020 回答