Skip to content

Commit 08c4269

Browse files
committed
fix: ensure BMI calculation returns a number and not a string
1 parent fb74158 commit 08c4269

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111

1212
function calculateBMI(weight, height) {
1313
let bmi = (weight / (height * height));
14-
return bmi.toFixed(1);
14+
return Number(bmi.toFixed(1));
1515
}
1616
console.log(calculateBMI(70, 1.73));
1717
console.log(calculateBMI(95, 1.82));
1818
console.log(calculateBMI(52, 1.6));
1919
console.log(calculateBMI(110, 1.75));
20-
console.log(calculateBMI(65, 1.9));
20+
console.log(calculateBMI(65, 1.9));
21+
22+
console.assert(typeof calculateBMI(60, 1.65) === 'number', 'Should return a number');
23+
console.assert(calculateBMI(60, 1.65) === 22.0, 'Should correctly calculate BMI');
24+
console.log('All tests passed!');

0 commit comments

Comments
 (0)