27. help,pls


#1


Help, anyone tell me what did wrong, pls?
Thank you,


SyntaxError: Unexpected token )


Replace this line with your code. 
// 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++, i < family.length) {
    console.log(family[i].name);
};


#2

Make sure you have semicolons in your for loop and not commas to separate the parts of that loop.


#3

Yeah, you r right!
but there are still something wrong in this code.


#4

Is it still showing the same error message?


#5

nope, we fixed it but it unable to log the name:

Oops, try again. Make sure to log to the console the name of each object


#6

Maybe take a look at your for loop. Syntax-wise, a Javascript for loop basically looks like this:

for (starting point; ending point; increment/decrement) {
    //random code
};

You may have your for loop statement order wrong.


#7

yeah, it's work, thank you for remind me.


#8

No problem! Happy coding :slight_smile:


#9

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