Skip to content

Commit 48d2e3a

Browse files
feat: implement BMI calculation function and add example usage
1 parent fdf492e commit 48d2e3a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19-
}
19+
const heightSquared = height * height; // square the height
20+
const bmi = weight / heightSquared; // calculate BMI by dividing weight by height squared
21+
const roundedBmi = bmi.toFixed(1); // round the result to 1 decimal place
22+
return roundedBmi; // return the rounded BMI value
23+
}
24+
console.log(calculateBMI(70, 1.73)); // Example usage: should return 23.4
25+
console.log(calculateBMI(80, 1.8)); // Example usage: should return 24.7

0 commit comments

Comments
 (0)