Let's go back to Mark and John comparing their BMIs!
This time, you'll use JavaScript objects to implement the BMI calculations.
π‘ Remember:
BMI formula = mass / (height Γ height)
(mass in kg and height in meters)
Create two objects:
fullName
mass
height
β οΈ Use the exact object names
mark
andjohn
, and the property namesfullName
,mass
, andheight
.
Add a method calcBMI
to each object that:
bmi
(lowercase)bmi
valueCompare BMIs:
"John Smith's BMI (28.3) is higher than Mark Miller's (23.9)!"
Mark:
John:
"John Smith's BMI (24.2) is higher than Mark Miller's (23.9)!"
Make sure youβre using methods and the this
keyword properly inside the objects!
Happy coding! π