27.Loop the loop


#1

The exercise I'm stuck at

I read through my code a few times but can't find the error. I get a SyntaxError: Unexpected token [ .
Any help would be appreciated.


// 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();

var family[0] = new Person("alice",40);
var family[1] = new Person("bob",42);
var family[2] = new Person("michelle",8);
var family[3] = new Person("timmy",6);
// loop through our new array
for(i=0; i<family.length; i++){
    console.log(family[i].name);
}


#2

Hi this part

var family[0] = new Person("alice",40);
var family[1] = new Person("bob",42);
var family[2] = new Person("michelle",8);
var family[3] = new Person("timmy",6);

you should remove the var


#3

Oops. Someone forgot how arrays work. :smiley:

Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.