Discuss / JavaScript / 练习

练习

Topic source

'use strict';

var height = parseFloat(prompt('请输入身高(m):')); var weight = parseFloat(prompt('请输入体重(kg):'));

var ibm = height/Math.pow(weight , 2); if (ibm<18.5){ alert('过轻'); } else if(ibm<25){ alert('正常'); } else if(ibm<28){ alert('过重'); } else if(ibm<32){ alert('肥胖'); } else { alert('严重肥胖'); }


  • 1

Reply