Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit 5969272

Browse files
committed
feat: Challenge 7 of JS Fundamentals Done
1 parent 3e05cda commit 5969272

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const mark = {
2+
fullName: "Mark Miller",
3+
mass: 78,
4+
height: 1.69,
5+
bmi: 0,
6+
calcBMI: function () {
7+
let bmi = this.mass / (this.height * this.height);
8+
this.bmi = bmi;
9+
return bmi;
10+
}
11+
};
12+
13+
const john = {
14+
fullName: "John Smith",
15+
mass: 92,
16+
height: 1.95,
17+
bmi: 0,
18+
calcBMI: function () {
19+
let bmi = this.mass / (this.height * this.height);
20+
this.bmi = bmi;
21+
return bmi;
22+
}
23+
};
24+
25+
mark.calcBMI();
26+
john.calcBMI();
27+
28+
if (mark.bmi > john.bmi) {
29+
console.log(`${mark.fullName}'s BMI (${mark.bmi}) is higher than ${john.fullName}'s (${john.bmi})!`)
30+
} else if (john.bmi > mark.bmi) {
31+
console.log(`${john.fullName}'s BMI (${john.bmi}) is higher than ${mark.fullName}'s (${mark.bmi})!`)
32+
}

0 commit comments

Comments
 (0)