27.Loop the loop



Oops, try again. It looks like the object at index 0 was not created with the Person constructor

// 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<family.length; i++) {

I cant seem to find the problem with my code and i dont understand the error message. Anyone that can help me out? Thank you in advance.


var family = new array();

When we define an Array using Array object we use

new Array() not new array() (Capitalized A)

Can you catch the difference?
Also its not considered to be a good practice.

use [] instead of that!


Found my typo, thx for spotting it!

Got curious and tried to use an array literal notation instead. It works, but the lesson sadly insists that you use "bad practice?" to solve the lesson, in the form of a object constructor.

But thanks for the tip anyway.



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