var johnObj = {
calJonBMI: function () {
this.BMI = this.mass / (this.height * this.height);
return this.BMI;
}
};
johnObj.fullName = "john cena";
johnObj.mass = 40;
johnObj.height = 5.6;
console.log(johnObj);
console.log(johnObj.fullName+"'s BMI is:"+johnObj.calJonBMI());
var markObj = {
calJonBMI: function () {
this.BMI = this.mass / (this.height * this.height);
return this.BMI;
}
};
markObj.fullName = "mark waugh";
markObj.mass = 45;
markObj.height = 6.5;
console.log(markObj);
console.log(markObj.fullName+"'s BMI is:"+markObj.calJonBMI());
if(johnObj.BMI>markObj.BMI){
console.log(johnObj.fullName+" BMI is greater than "+markObj.fullName);
}
else if(markObj.BMI>johnObj.BMI){
console.log(markObj.fullName+" BMI is greater than "+johnObj.fullName);
}
else{
console.log(markObj.fullName+" BMI and"+johnObj.fullName+" are equal");
}
No comments:
Post a Comment