17/33 This works for everyone


#1

Hey guys I'm having trouble here please help.
"Oops, try again. It looks like you have an error in your code. Here's the message: TypeError: susan.setAge is not a function". Idk what is wrong with my code:

// 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 = {
age: 25
}

// here, update Susan's age to 35 using the method
susan.setAge(35);


#2

you just forgot to set the susan.setAge method to equal setAge function. Should be:
var susan = {
age: 25
};
susan.setAge = setAge;
susan.setAge(35);


#3

Why your create susan like this:
var susan = {
age: 25
};
In this lesson we learning constructor and this

.
So my option is:

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