#27 Person Constructor


#1

// Our Person constructor
function Person(name, age) {
this.name = name;
this.age = age;
}
// Now we can make an array of people
var family = new Array();
family[0] = Person("alice", 40);
family[1] = Person("bob", 42);
family[2] = Person("michelle", 8);
family[3] = Person("timmy", 6);
// loop through our new array
for (var f = 0; f < family.length; f++) {
console.log(family[f].name)
};

// My error says the objects in index 0 wasn't made with the person constructor. WHY?! Dx


#2

Hey @sirfredrickrex2_0 - you're missing 'new' in your array of people. It should have:

family[0] = **new** Person ("alice", 40);