-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7020327
commit 9f744b3
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,40 @@ | ||
const calculate = document.getElementById("calculate"); | ||
|
||
const bmiVal = document.getElementById("result-num"); | ||
const resultText = document.getElementById("result-text"); | ||
const resultTitle = document.getElementById("result-block-title"); | ||
//display calculated BMI value | ||
let BMI = localStorage.getItem("BMI"); | ||
|
||
//calculate button | ||
BMI = parseFloat(BMI); | ||
BMI = BMI.toFixed(1); | ||
bmiVal.innerText = BMI; | ||
//display BMI message | ||
switch(true) { | ||
case BMI < 18.5: | ||
resultTitle.innerText ="Underweight"; | ||
resultTitle.style.color = "#4287f5"; | ||
resultText.innerText = "You are underweight."; | ||
break; | ||
case BMI >= 18.5 && BMI <= 24.9: | ||
resultTitle.innerText ="Healthy"; | ||
resultText.innerText = "You are a healthy weight."; | ||
break; | ||
case BMI >= 25 && BMI <= 29.9: | ||
resultTitle.innerText ="Overweight"; | ||
resultTitle.style.color = "#f5e942"; | ||
resultText.innerText = "You are overweight."; | ||
break; | ||
case BMI > 30 && BMI <= 39.9: | ||
resultTitle.innerText ="Obese"; | ||
resultTitle.style.color = "#eb923f"; | ||
resultText.innerText = "You are obese."; | ||
break; | ||
case BMI >= 40: | ||
resultTitle.innerText ="Severly Obese"; | ||
resultTitle.style.color = "#cc2823"; | ||
resultText.innerText = "You are severly obese."; | ||
break; | ||
} | ||
//re-calculate button | ||
calculate.addEventListener('click', () => { | ||
location.href = "index.html"; | ||
}) |
This file contains 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