Skip to content

Commit 49136ce

Browse files
committed
Replace .toFixed with Math.round to avoid convert numbers to string
1 parent 503eb4f commit 49136ce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

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

1717
function calculateBMI(weight, height) {
18-
const bmi = (weight / (height * height)).toFixed(1); //.toFixed(1)https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
18+
const bmi = Math.round((weight / (height * height)) * 10) / 10;
1919
return bmi;
2020
// return the BMI of someone based off their weight and height
2121
}

0 commit comments

Comments
 (0)