ReferenceError: array is not defined


#1


https://www.codecademy.com/courses/spencer-sandbox/4/2?curriculum_id=506324b3a7dffd00020bf661


ReferenceError: array is not defined


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


#2

this line:

var family = new array();

Array should spelled with uppercase first letter

then your loop:

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

you want to get the length of family (family.length) and you want to use < instead of <= given the length is 4, but arrays are zero indexed based, so you want lesser then 4, not equal or lesser then 4


#3

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