Skip to content

Commit 77770dd

Browse files
Simplified Function
1 parent fa6a305 commit 77770dd

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

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

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

1717
function calculateBMI(weight, height) {
18-
let numWeight = Number(weight.slice(0, -2));
19-
let numHeight = Number(height.slice(0, -1));
20-
let BMI = numWeight / (numHeight * numHeight);
21-
return Math.round(BMI * 10) / 10;
18+
let BMI = weight / (height * height);
19+
return (BMI * 10) / 10;
2220
}
2321

24-
console.log(`Your BMI is: ${calculateBMI("70kg", "1.83m")}`);
22+
console.log(`Your BMI is: ${calculateBMI(70, 1.83)}`);

0 commit comments

Comments
 (0)