-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Expand file tree
/
Copy pathcodingChallenge_2.js
More file actions
41 lines (38 loc) · 787 Bytes
/
codingChallenge_2.js
File metadata and controls
41 lines (38 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* function bmi(mass, height) {
return mass / height ** 2;
}
console.log(bmi(78, 1.69));
console.log("Break\nBreak\nBreak");
*/
let mark = {
name: "Mark",
mass: 78,
height: 1.69,
bmi: function () {
bmi = this.mass / this.height ** 2;
return bmi.toFixed(2);
},
};
let john = {
name: "John",
mass: 92,
height: 1.95,
bmi: function () {
bmi = this.mass / this.height ** 2;
return bmi.toFixed(2);
},
};
if (mark.bmi() > john.bmi()) {
return console.log(
`${mark.name}'s BMI (${mark.bmi()}) is higher than ${
john.name
}'s (${john.bmi()})!`
);
} else if (john.bmi() > mark.bmi()) {
return console.log(
`${john.name}'s BMI (${john.bmi()}) is higher than ${
mark.name
}'s (${mark.bmi()})!`
);
}
module.exports = bmi;