var bmi= weight/(Math. pow(height,2)); while((height>3||height<0.2||weight<=0||weight>500)){ alert("输入异常,重新输入"); height = parseFloat(prompt('请输入身高(m):')); 确定 weight = parseFloat(prompt('请输入体重(kg):')); } if(bmi>32)alert("严重肥胖"); else if((bmi>28)&&(bmi<32))alert("肥胖"); else if((bmi>25)&&(bmi<28))alert("过重"); else if((bmi>18.5)&&(bmi<25))alert("正常"); else {alert("过轻");} console.log(bmi);
插入的时候莫名其妙多了个确定
Sign in to make a reply
乄噬灬翼丶