Loop the Loop



It keeps printing alice, but won't print anyone else? What's wrong with the 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 i = 0; i < Person.name; i++); {


@melimelicxo This is what is wrong:

change this:

to this:


then change this:

to this:


Hope this helps



for (var i = 0; i < Person.name; i++); { // here remove ;

and what is the value of Person.name ????
so write family.length instead of Person.name


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