Skip to content

Commit b5f6fa6

Browse files
committed
Refactor calculateBMI function to directly return BMI value
1 parent ca134f6 commit b5f6fa6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ function calculateBMI(weight, height) {
1919
throw new Error('Height must be greater than 0');
2020
}
2121
const heightSquared = height ** 2;
22-
const bmi = weight / heightSquared;
22+
return weight / heightSquared;
23+
}
24+
function formatBMI(bmi){
2325
return bmi.toFixed(1); // rounds 'bmi' to 1 decimal place and converts to a string
2426
// return the BMI of someone based off their weight and height
25-
}
26-
console.log(`The Body Mass Index is: ${calculateBMI(70, 1.73)}`);
27+
}
28+
29+

0 commit comments

Comments
 (0)