4 listing everybody


hey guys, i dont know what is wrong. its saying syntaxError. please help!

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: "mary.johnson@example.com"

var contacts = [bob, mary];

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
 var list = function () {
     var contactsLength = contacts.length;
     for (i = 0; i < contacts.length i++) {


Hi there,

I've managed to pick up a few things. I'd be glad to help you out.

First of all the syntax error, you're getting is caused by your for loop syntax; you're missing a semi-colon separating contact.length from i++.

Secondly, you're going to run into more troubles because as far as I can tell you haven't made an object of bob, yet you are referencing it in your contacts list on line 8. So it's best you either remove bob from the list or create an object for him like you have for mary.

Lastly, I'd just like to point out that line 14 var contactsLength = contacts.length; is redundant because you don't use the contactsLength variable in your for loop conditions.

I hope that makes sense and enables you to finish this exercise. Lemmie know if you need more help.


thanks so much for replying.
i made bob already before mary, i forgot to copy it when i was copying my code.
thanks for pointing out the semi-colon for me. i totally missed it.

i guess in the for loop i was supposed to write
for (i = 0; i < contactslength; i++)

or just remove the variable like u suggested.

thanks for helping


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