What does this error message mean!


#1


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


when I run my code I'm not entirely sure what happens, but it prints out the four names and an error message that says TypeError: Cannot read property 'name' of undefined


var Person = function(name, age)
{
    this.age = age;
    this.name = name;
};

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);

for(i = 0; i <= family.length; i++)
{
    console.log(family[i].name + " ");
};


#2

speciically, it prints this to the console:

alice
bob
michelle
timmy


We're running a test below to make sure your code works.
alicebobmichelletimmy
TypeError: Cannot read property 'name' of undefined


#3

There is the reason, There is no family[4].


#4

thanks (i feel like an idiot)


#5

Don't. It's a common error, and one you will likely not make again. So be good to yourself.


#6

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