Loop the loop


I'm having trouble creating a constructor. An error pops up and it keeps saying

"Oops, try again.
When trying to create a new Person the following error was thrown: TypeError: Person is not a constructor"

Am I constructing it wrong? How can I fix it? Here is the code.

// Our Person constructor
var Person = new Object(name, 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++){


If you consider for a moment what the purpose of a constructor is, then I think you'll agree that it won't look anything like what you did. So what would it look like? I imagine this exercise or some recent one was about just that? More importantly, don't guess when you can find out, it's a terrible substitute!


Ok, I found out the problem and the proper syntax I was meant to be using.

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


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