Introduction to Objects I: Loop the Loop


#1

...help?
Here's my code:

// 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] = 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(x = 0; x <= family.length; x++) {
console.log(family[x].name);
}


#2

@tardisflyer124
Remove the = in your for statement or else it'll stop at the family.length which is the index number 3 and won't print that out.


#3

That fixed the problem. Thank you!