Created
February 23, 2021 11:06
-
-
Save Wanuja97/e2a7293dc535152e48d1093d5e321139 to your computer and use it in GitHub Desktop.
BMI Calculator - JavaScript Part
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Calculate(){ | |
var height = document.getElementById("h-input").value; | |
var weight = document.getElementById("w-input").value; | |
var result = parseFloat(weight) /(parseFloat(height)/100)**2; | |
if(!isNaN(result)){ | |
document.getElementById("bmi-output").innerHTML = result; | |
if(result < 18.5){ | |
document.getElementById("bmi-status").innerHTML = "Underweight"; | |
} | |
else if(result < 25){ | |
document.getElementById("bmi-status").innerHTML = "Healthy"; | |
} | |
else if(result < 30){ | |
document.getElementById("bmi-status").innerHTML = "Overweight"; | |
} | |
else{ | |
document.getElementById("bmi-status").innerHTML = "Obesity"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment