Skip to content

Commit dd2ba45

Browse files
committed
implement calculateBMI function -> divides weight by height squared, returns 1dp
1 parent aa93d90 commit dd2ba45

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19-
}
19+
const bmi = weight / (height * height);
20+
return Number(bmi.toFixed(1));
21+
}
22+
console.log(calculateBMI(58, 1.64)); // 21.6
23+
console.log(calculateBMI(70, 1.73)); // 23.4
24+
console.log(calculateBMI(90, 1.8)); // 27.8

0 commit comments

Comments
 (0)