Skip to content

Commit 9417991

Browse files
committed
Refactor calculateBMI function to use toFixed for consistent decimal formatting
1 parent 2cae221 commit 9417991

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

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

1717
function calculateBMI(weight, height) {
18-
const bmi = weight / (height * height);
19-
return Math.round(bmi * 10) / 10;
18+
const bmi = weight / (height * height);
19+
return Number(bmi.toFixed(1));
20+
}
21+
2022
}
2123

2224
console.log(calculateBMI(90, 1.85)); // should return 26.3

0 commit comments

Comments
 (0)