17. "This" Works for Everyone help


#1

Can someone please explain whats wrong with this code?
thanks beforehand

// here we define our method using "this", before we even introduce bob
var setAge = function (newAge) {
this.age = newAge;
};
// now we make bob
var bob = new Object();
bob.age = 30;
bob.setAge = setAge;

// make susan here, and first give her an age of 25

var susan = new Object();
susan.age = 25;

susan.setAge(35);

// here, update Susan's age to 35 using the method


#2

you didn't take the help of "this" here...

add, susan.setAge=setAge; before susan.setAge(35);


#3

Okay thank you very much =)