Discuss / JavaScript / 也可以这样写吧

也可以这样写吧

Topic source

Jay枫若情

#1 Created at ... [Delete] [Delete and Lock User]
var Jay={
            weight:80.5,
            height:1.75,
            BMI:function(){
                var bmi=this.weight/(this.height*this.height)
                return bmi
            }
        }
        if(Jay.BMI()<18.5)alert("too light")
        else if(Jay.BMI()>=18.5 && Jay.BMI()<25)alert("Congratulation, you are normal size.")
        else if(Jay.BMI()>=25 && Jay.BMI()<28)alert("too heavy")
        else if(Jay.BMI()>=28 && Jay.BMI()<32)alert("fat")
        else alert("Obesity serious")

  • 1

Reply