File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Sprint-2/3-mandatory-implement Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1414// Then when we call this function with the weight and height
1515// It should return their Body Mass Index to 1 decimal place
1616
17+ /**
18+ * Original function:
19+ * function calculateBMI(weight, height) {
20+ * return the BMI of someone based off their weight and height
21+ *}
22+ */
23+
1724function calculateBMI ( weight , height ) {
18- // return the BMI of someone based off their weight and height
19- }
25+ // Calculate BMI: weight divided by height squared
26+ const bmi = weight / ( height * height ) ;
27+
28+ // Return the result rounded to 1 decimal place using the built-in Math library
29+ return Math . round ( bmi * 10 ) / 10 ;
30+ }
31+
32+ // Test the function
33+ console . log ( calculateBMI ( 70 , 1.73 ) ) ; // Should output: 23.4
34+ console . log ( calculateBMI ( 80 , 1.80 ) ) ; // Test with another example and returns 24.7
35+
You can’t perform that action at this time.
0 commit comments