File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 11// Below are the steps for how BMI is calculated
2-
32// The BMI calculation divides an adult's weight in kilograms (kg) by their height in metres (m) squared.
4-
53// 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:
6-
74// squaring your height: 1.73 x 1.73 = 2.99
85// dividing 70 by 2.99 = 23.41
96// Your result will be displayed to 1 decimal place, for example 23.4.
10-
117// You will need to implement a function that calculates the BMI of someone based off their weight and height
12-
138// Given someone's weight in kg and height in metres
149// Then when we call this function with the weight and height
1510// It should return their Body Mass Index to 1 decimal place
1611
1712function calculateBMI ( weight , height ) {
18- // return the BMI of someone based off their weight and height
19- }
13+ var bmi = ( weight / ( height * height ) ) ;
14+ return bmi . toFixed ( 1 ) ;
15+ }
16+ console . log ( calculateBMI ( 70 , 1.73 ) ) ;
17+ console . log ( calculateBMI ( 95 , 1.82 ) ) ;
18+ console . log ( calculateBMI ( 52 , 1.6 ) ) ;
19+ console . log ( calculateBMI ( 110 , 1.75 ) ) ;
20+ console . log ( calculateBMI ( 65 , 1.9 ) ) ;
You can’t perform that action at this time.
0 commit comments