27 help please


Any ideas as to why this error is happening? I've compared it with other people's code that has been exactly identical and it won't work for me but will for them...


This error keeps popping up and I dont know why:
Oops, try again. There was a problem with your syntax.
SyntaxError: Unexpected token [

// 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();
var family[0] = new Person("alice", 40);
var family[1] = new Person("bob", 42);
var family[2] = new Person("michelle", 8);
var family[3] = new Person("timmy", 6);
// loop through our new array
for(var i = 0; i < family.length; i++)

thanks again for any input


is first found here...

We already have declared and defined family as an empty array. Now we just need to load it up.

family[0] = ...

Further about the error, We cannot declare an array element, hence, var family = [] to start off.


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