It seems I'm totally lost....this....16


#1

I think I have no idea what I'm expected to do.

https://www.codecademy.com/courses/spencer-sandbox/2/4?curriculum_id=506324b3a7dffd00020bf661

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

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

thanks in adv


#2

bob.setAge now equals the function setAge (in the 2nd line). In order to set Bob's age you have to call the setAge function inside of the object "bob". You can use the dot or the rectangular-brackets notation to do that. :wink:


#3

Thanks for your reply, but nothing is still working. Can you explain better?


#4

var setAge = function (newAge) {
this.age = newAge;
};
var bob = new Object();
bob.age = 30;
bob.setAge = setAge;
setAge= 50;


#5

instead of the line above, call bob.setAge(50);


#6

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