Introduction to Objects I - Loop the loop - 27/33 - Q&A


#1

I am on Loop the loop 27/33 and the error is: SyntaxError: function statement requires a name. I don't know how to solve it. Any ideas?

Thanks in advance!

// Our Person constructor
function = Person (name, age) {
    this.name = name;
    this.age = age;
}
// Now we can make an array of people
var family = 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(i = 0; i < family.length; i++) {
    console.log(family[i]);
};

#2

lets start here:

function = Person (name, age)

you assign a value of Person to function keyword? to make your own object constructor:

function ObjectName

no equal sign

var family = Array();

you want to make a new array, the new is missing

if you need more help, post an updated version of your code


#3

Thanks @stetim94! It works now! :smiley:


#4