Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 7, 2016 03:19
Show Gist options
  • Save codecademydev/229d46127da3d815cea9baf270322c0a to your computer and use it in GitHub Desktop.
Save codecademydev/229d46127da3d815cea9baf270322c0a to your computer and use it in GitHub Desktop.
Codecademy export
// Our Person constructor
function Person(name, age) {
this.name = name;
this.age = age;
}
// Now we can make an array of people
var family = [];
family[0] = new Person("alice", 40);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);
// loop through our new array
for (var i = 0; i < family.length; i++) {
console.log(family[i].name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment