Skip to content

Commit 01ee9fd

Browse files
Implement calculateBMI in 3-mandatory-implement/1-bmi.js
1 parent 69f740e commit 01ee9fd

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,9 @@
44

55
// For example, if you weigh 70kg (around 11 stone) and are 1.73m (around 5 feet 8 inches) tall, you work out your BMI by:
66

7-
// squaring your height: 1.73 x 1.73 = 2.99
8-
// dividing 70 by 2.99 = 23.41
9-
// Your result will be displayed to 1 decimal place, for example '23.4'.
10-
11-
// You will need to implement a function that calculates the BMI of someone based off their weight and height
12-
13-
// Given someone's weight in kg and height in metres
14-
// Then when we call this function with the weight and height
15-
// It should return a string of their Body Mass Index to 1 decimal place
16-
177
function calculateBMI(weight, height) {
188
// return the BMI of someone based off their weight and height
9+
const bmi = weight / (height * height);
10+
return bmi.toFixed(1);
1911
}
12+
console.log(calculateBMI(70, 1.73));

0 commit comments

Comments
 (0)