Hi everybody first time posting here.
So I am trying to understand something, I will post the code here too, but if you want to check out the source, its this " https://www.codecademy.com/en/courses/spencer-sandbox/2/5?curriculum_id=506324b3a7dffd00020bf661 "
Which is an exercise from codeacademy....
So there is bob.setAge = setAge; , why didn't it make it so bob.setAge= newAge; ??
here is the code .
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 = setAge;
// here, update Susan's age to 35 using the method
susan.setAge(35);
setAgeis a function ... later you can call itbob.setAge(30).