File tree Expand file tree Collapse file tree
Sprint-3/3-mandatory-implement Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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-
177function 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 ) ) ;
You can’t perform that action at this time.
0 commit comments