17. "This" Works for Everyone


// 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.setAge= setAge;

// here, update Susan's age to 35 using the method
var setAge= function (newAge) {
this.age = newAge;

Here is my code i keep getting the Error message "Oops, try again. Make sure to set susan's setAge property to be the setAge function"

Please Help


The only things I see immediately wrong is that you've missed out a couple of semi-colons (after susan.age=25 and susan.setAge(35)). You also don't need to write out the setAge function again, as it's already defined at the top of the code.

Fix those and see if it passes this time, but let me know if it doesn't.


I figured out that You have to declare the variable and function before you declare Susan and you have to put in the semicolon after both susan.age=25 and susan.setAge(35))