Array Creation


#1

HELPPPPPPP. please :slightly_smiling:

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 (var family = 0; family < 4; family++) {
family[0].name;
family[0].age;
family[1].name;
family[1].age;
family[2].name;
family[2].age;
family[3].name;
family[3].age;
}

Error Message:

Make sure you created an Array called family


#2

@brocktikson,

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);
console.log( family );

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for


#3

I tried that, just the addition of the console.log statement, it didn't really work