Loop to loop intro to objects/27


#1

Could someone tell me where I'm going wrong with this code. I'm thinking my logic/format is incorrect in the for loop. Error message states //SyntaxError: expected expression, got ';' //

// Our Person constructor
function Person(name, age);
this.name = name;
this.age = age;

// Now we can make an array of people
family = new Array(){
family[0] = new Person("alice",42);
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 < Person.name.length; i++){
console.log(i);
};


#2

1.missing curly bracket
it should be like

function Person(name,age){
this.name=name;
this.age=age;
};

2.family should be in variable.like

var family=new Array();

3.remove curly bracket after family = new Array()

family = new Array(){<= remove
family[0] = new Person("alice",42);
family[1] = new Person("bob", 42);
family[2] = new Person("michelle", 8);
family[3] = new Person("timmy", 6);
};<= remove

4.think what should be your for loop


#3

Hi and here

for(var i = 0; i < Person.name.length; i++)

you want to

// loop through our new array

family