Skip to content

Commit 68330f6

Browse files
committed
variable created to hold calculation, plus rounding done in the function
1 parent 734cbfe commit 68330f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

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

1717
function calculateBMI(weight, height) {
18-
height = height * height;
19-
return weight / height;
18+
const bmi = weight / (height ** 2);
19+
return Number(bmi.toFixed(1));
2020
}
2121

22-
console.log("Your BMI is: " + calculateBMI(70, 1.73).toFixed(1))
22+
console.log("Your BMI is: " + calculateBMI(70, 1.73))

0 commit comments

Comments
 (0)