Skip to content

Commit bc36994

Browse files
committed
Write and test calculateBMI function in 1-bmi.js
1 parent 46ff75c commit bc36994

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@
1515
// It should return a string of their Body Mass Index to 1 decimal place
1616

1717
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
18+
return Number.parseFloat(weight / (height * height)).toFixed(1);
1919
}
20+
21+
// Tests
22+
console.log(calculateBMI(55, 1.63));
23+
console.log(calculateBMI(120, 1.73));
24+
console.log(calculateBMI(80, 1.69));
25+
console.log(calculateBMI(51, 1.55));
26+
27+
// Please could I have a little feedback about if I have refactored the function return too much?
28+
// And if so, what is a good guide on how many operations to perform in one line..? I can also
29+
// ask this in class if you prefer.

0 commit comments

Comments
 (0)