37 lines
842 B
JavaScript
37 lines
842 B
JavaScript
const mark = {
|
|
firstName: "Mark",
|
|
lastName: "Miller",
|
|
fullName: `${this.firstName} ${this.lastName}`,
|
|
mass: 78,
|
|
height: 1.69,
|
|
bmi: null,
|
|
calcBMI: function () {
|
|
this.bmi = this.mass / (this.height * this.height);
|
|
return this.bmi;
|
|
},
|
|
};
|
|
|
|
const john = {
|
|
firstName: "John",
|
|
lastName: "Smith",
|
|
fullName: `${this.firstName} ${this.lastName}`,
|
|
mass: 92,
|
|
height: 1.95,
|
|
bmi: null,
|
|
calcBMI: function () {
|
|
this.bmi = this.mass / (this.height * this.height);
|
|
return this.bmi;
|
|
},
|
|
};
|
|
|
|
const higherBMI = function () {
|
|
john.calcBMI();
|
|
mark.calcBMI();
|
|
|
|
return john.BMI > mark.bmi
|
|
? `${john.firstName}'s BMI (${john.bmi}) is higher than ${mark.firstName}'s (${mark.bmi})! `
|
|
: `${mark.firstName}'s BMI (${mark.bmi}) is higher than ${john.firstName}'s (${john.bmi})! `;
|
|
};
|
|
|
|
console.log(higherBMI());
|