Listing Everybody


#1



https://www.codecademy.com/courses/building-an-address-book/0/4?curriculum_id=506324b3a7dffd00020bf661


My code is not working. Please help. The error message is: SyntaxError: missing after for-loop initializer


Replace this line with your code. 
var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: "bob.jones@example.com"
};

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 contacts = contactsLength;
    for(var i = 0, i < contacts.length, i++) {
        printPerson(contacts[i]);
    }
};

list();


#2

Notice anything? You're using commas instead of semicolons in your for loop. It should look like this instead:

for(var i = 0; i < contacts.length; i++)


#3

instead of

var contacts = contactsLength;

write:

var contactsLength = contacts.length;


#4

Thank you both. It works now :slight_smile:


#5

No problem, I'm always glad to help :slight_smile:


#6

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