Skip to content

Commit bd99bf5

Browse files
committed
Learn toFixed & parseFloat
1 parent 7d6b8da commit bd99bf5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,14 @@
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 heightSquare = height * height;
19+
let wheightCal = weight / heightSquare;
20+
let result1 = wheightCal.toFixed(1);
21+
//toFixed() returns a string, not a number.
22+
// need to convert the result to a number
23+
let tranftoNumber= parseFloat(result1);
24+
return tranftoNumber;
25+
}
26+
27+
console.log (calculateBMI (56, 1.65))
28+
// return the BMI of someone based off their weight and height

0 commit comments

Comments
 (0)