27 Loop the loop


#1


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


Im confuse and i dont know what to do ive tried as much as i could.


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

// Now we can make an array of people
var family = [];
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 <= family.length; i++) {
    console.log("My name is " + family[i].name);
}


#2

Note the uppercase P. Convention dictates we name classes with a capital letter.

function Person( ... ) {}

Because of zero indexing we stop before array.length.

i < family.length

The instructions ask for only the name, not embellished text. For best results do not write things into the code if not asked to.


#3

4 posts were split to a new topic: Help us understand what we do wrong?


#4