Question: What will the following code output to the console? const obj = { x: 1 0 , y: 2 0 , z: { a: 5

What will the following code output to the console?
const obj ={
x: 10,
y: 20,
z: {
a: 5,
b: 15,
},
calculate: function(){
let sum = this.x + this.y;
for (let key in this.z){
sum += this.z[key];
}
return sum;
}
};
console.log(obj.calculate());
50
45
25
30
Clear my selection

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!