Help needed on 27/33


#1

This is my code for 27/33 and I keep getting a SyntaxError: Unexpected token ( error - can anyone help?

// Our Person constructor
var 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 (i = 0; i < family.length; i++) {
console.log(family[i].name);
};


#2

Hi there,
in line 2 you used var instead of function.


#3

AHA! Thank you so much :smile:


#4

There are two ways to define a function
-1 via a variable with an associated so-called anonymous function

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

-2 defining a so-called named function

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

Have a read...