Before getting into this topic,you should know how to create a simple website in WordPress.To those who dont know you can see my tutorial on it by clicking the button below.
1.JAVASCRIPT BMI CODING-SNIPPET
height=prompt("Enter your height in metres");
weight=prompt("Enter your weight in kg" );
calBmi();
function calBmi(){
bmi=(weight)/(height*height);
alert("Your bmi is " + bmi.toFixed(2));
}
2.JAVASCRIPT BMI-IF ELSE
height=prompt("Enter your height in metres");
weight=prompt("Enter your weight in kg" );
calBmi();
if(bmi<24.9) alert ("BMI ="+bmi.toFixed(2)+" .Your bmi is underweight");
else if(bmi>=18.5 && bmi<=24.9) alert ("BMI ="+bmi.toFixed(2)+" .Your bmi is normal");
else if(bmi<24.9) alert ("BMI ="+bmi.toFixed(2)+" .Your bmi is underweight");
else if(bmi>=25 && bmi<=29.9) alert ("BMI ="+bmi.toFixed(2)+" .Your bmi is overweight");
else alert("BMI ="+bmi.toFixed(2)+" .Your bmi is overweight");
function calBmi(){
bmi=(weight)/(height*height);
}
You must be logged in to post a comment.