The console says the value is undefined
const pc = {
brandname: "hp",
modelName: "hp-221Gt",
cpu: {
brandname: "hp",
motherBoard: "inteLiCore",
raminGB: 4,
rominGB: 1024,
processore: "Octacore",
processorMaxSpeedinGHz: 3.8,
},
powerOn: "yes",
// powerOff : false,
newPowerStatus: function (on) {
this.powerOn = on;
// this.powerOff = off;
},
run: function () {
return this.newPowerStatus(on);
}
}
console.log(pc);
console.log("The cpu I use has following specs : ", pc.cpu)
console.log("Is the pc running : ", pc.newPowerStatus.on);
var show = "powerOn";
console.log(pc[show])
console.log(pc.run);
I tried to call the string value of a property in the console through the function.