We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fdf492e commit 48d2e3aCopy full SHA for 48d2e3a
Sprint-2/3-mandatory-implement/1-bmi.js
@@ -16,4 +16,10 @@
16
17
function calculateBMI(weight, height) {
18
// return the BMI of someone based off their weight and height
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