Let's go back to Mark and John comparing their BMIs! This time, let's use objects to implement the calculations!
BMI = mass / height **2 = mass / (height * height).
Mass in kg
and height in meter
.
- For each of them, create an object with properties for their full name, mass, and height (Mark Miller and John Smith).
- Create a
calcBMI
method on each object to calculate theBMI
(the same method on both objects). Store theBMI
value to a property, and also return it from the method. - Log to the console who has the higher BMI, together with the full name and the respective BMI.
"John Smith's BMI (28.3) is higher than Mark Miller's (23.9)!"
Marks weighs 78kg
and is 1.69m
tall. John weighs 92kg
and is 1.95m
tall.
Gooluck 😁