Skip to content

Commit 3c47903

Browse files
committed
update: Implement calculateBMI function to compute Body Mass Index based on weight and height, including detailed comments for clarity in Sprint-2/3-mandatory-implement/1-bmi.js
1 parent 5d354cd commit 3c47903

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

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

1717
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
19-
}
18+
// return the BMI of someone based off their weight and height
19+
// calculate the height squared
20+
const heightSquared = height * height;
21+
// calculate the BMI
22+
const BMI = weight / heightSquared;
23+
// return the BMI to 1 decimal place
24+
return BMI.toFixed(1);
25+
}
26+
let weight = 70; // in kg
27+
let height = 1.73; // in meters
28+
29+
console.log(`BMI is ${calculateBMI(weight, height)}`);

0 commit comments

Comments
 (0)