Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 6, 2016 02:45
Show Gist options
  • Save codecademydev/fd29810212076eef8b5cb1e9f85de5f9 to your computer and use it in GitHub Desktop.
Save codecademydev/fd29810212076eef8b5cb1e9f85de5f9 to your computer and use it in GitHub Desktop.
Codecademy export
// 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.age = 25;
susan.setAge = setAge;
// here, update Susan's age to 35 using the method
susan.setAge(35);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment