Help


#1

Oops, try again. Make sure to log to the console the name of each object


// Our Person constructor
function Person(name, age)
{
    this.name = name;
    this.age = age;
};
    var family = new Array();
// Now we can make an array of people
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 arrayfamily
for(var i=0; i<length.family; i++)
{
    console.log(family[i].name);
};


#2

@chipsurfer71401,

for ([initialization]; [condition]; [final-expression]) {
   statement }

You will have to change your [condition] in your FOR-loop
from

i<length.family

into the correct

i<family.length

Reference:
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

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