const calculateBMI = function (weight, height) {
let BMI = weight / height ** 2;
return BMI;
};
const marksData = {
height: 1.69,
weight: 78,
msBMI: calculateBMI(this.weight, this.height),
};
const johnsData = {
height: 1.95,
weight: 92,
jsBMI: calculateBMI(this.weight, this.height),
};
console.log(marksData.msBMI);
console.log("something");
console.log(johnsData.jsBMI);
I don't know why the output of the function "const calculateBMI" inside two objects ("marksData" and "johnsData") is NaN, the problem I see here, is that the object:
const marksData = {
height: 1.69,
weight: 78,
msBMI: calculateBMI(this.weight, this.height),
};
is not catching a value of :
height: 1.69,
weight: 78,
like something is wrong whit this syntax (this.weight, this.height)