16/33 I don't understand this line: bob.setAge = setAge;


#1

Here is the code. Can someone please explain it to me in the most simplified way possible?

// 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;

// and down here we just use the method we already made
bob.setAge = setAge;

console.log(setAge);
// change bob's age to 50 here
bob.setAge(50);
console.log(bob.age);


#2

Just finished answering this for another member. Please see the following topic:

https://discuss.codecademy.com/t/17-bob-setage-setage/47564


#3

Thanks but I was even more confused by what you wrote! Can someone please explain it to me like I'm 5?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.