Skip to content

Commit ccccc5a

Browse files
In this , i make the height squared and then divide the weight by the height squared to get the BMI. I also used the toFixed method to round the BMI to one decimal place.
1 parent 36a8256 commit ccccc5a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19+
let squared_height = height * height;
20+
const bmi = weight/squared_height;
21+
return bmi.toFixed(1);
1922
}
23+
console.log(`The BMi of the person is ${calculateBMI(70,2.99)}`);
24+
// The output of the program is 'The BMi of the person is 7.8'.

0 commit comments

Comments
 (0)