What is wrong? (Intro to objects 27/33)


**It says I don't have an array called family. **

// 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 (i = 0; i < family.length; family++){


Hi @maxb55555

You have to change your "for" loop : (i++ not family++)

for (i = 0; i < family.length; i++)

Hold on :wink:


@maxb55555 you should use brackets with an array, not parentheses:

var family = new Array();


No, both ways work:

var family = new Array(); //works

var family[] = new Array {//code goes in here}


@freginold you have differents way to create an array, but they do exactly the same.

var family = new array();    //constructor method
var family = [];    //linear method

For simplicity we use the first one, but you can use what you want :smile:


@ragezapper and @onepunch_man thanks for pointing that out, didn't know you could do it either way. happy to learn something new.


your counter increment is incorrect, it should be i++ not family++