Problem in 27. Loop the loop


The code below isn't accepted for some reason, although I see the names printed out as they should be in the console.

// Our Person constructor
function Person(name,age)
{ = 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 <=family.length; i++)

I altered line 16 after that by changing




The code then gets accepted even though the output which I receive doesn't seem to be what is actually required (just the name is what is required)

Is this just a bug, or am I doing something wrong?



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

It should be i <family.length not i<=family.length

because length is always greater-than index

there is no value for family[4].name


Thanks Mr. rcodeman, that solved the issue!

For some reason, it still accepts this:

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


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