Skip to content

Commit 0b055f8

Browse files
implemented a function that calculates bmi with one decimal
1 parent 58fda13 commit 0b055f8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Sprint-2/3-mandatory-implement/1-bmi.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@
1515
// It should return their Body Mass Index to 1 decimal place
1616

1717
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
19-
}
18+
let sqh=height*height;
19+
let bmi=weight/sqh;
20+
let bmiS=bmi.toString()
21+
22+
23+
if(bmiS.includes(".")){
24+
let dotBmiS=bmiS.indexOf(".")
25+
return (Number(bmiS.slice(0,dotBmiS+2)))
26+
} return bmi
27+
28+
}
29+
console.log(calculateBMI(20,1.79));

0 commit comments

Comments
 (0)