Skip to content

Commit d1dfef3

Browse files
committed
The BMI function is updated
1 parent 17480c0 commit d1dfef3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
// Then when we call this function with the weight and height
1515
// It should return their Body Mass Index to 1 decimal place
1616

17-
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
17+
// I have made a small change to the test cases to ensure they match the expected output to 1 decimal place
18+
function calculateBMI(weight, height) {
19+
// Calculate BMI using the formula: weight (kg) / (height (m) * height (m))
20+
const bmi = weight / (height * height);
21+
22+
// Round to 1 decimal place and return
23+
return bmi.toFixed(1);
1924
}
20-
(calculateBMI(weight/hight*hight));
21-
let bmi = 85 / (1.54 * 1.54);
22-
console.log(bmi)
23-
//here the result was 35.833307439446366 I need to round it to 1 decimal place
24-
console.log(bmi.toFixed(1));
25-
//now the output is 35.8
26-
25+
26+
// Test cases
27+
console.log(calculateBMI(85, 1.54)); // 35.8
28+
console.log(calculateBMI(60, 1.65)); // 22.0
29+
console.log(calculateBMI(72, 1.80)); // 22.2
30+
// now the function is reusable and correct.

0 commit comments

Comments
 (0)