4. Listing Everybody


#1


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

Syntax Error: Invalid or unexpected token. This is my code I also copy and pasted code from a previous thread that said it worked for them in May. Any clues?


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


#2

HI this line

for(i=0; i<contactslength; i++)

you wrote contactslength instead of contactsLength


#3

Good eye! Still the same error unfortunately...


#4

Did you change another thing in your code because the one post when I made the change it works

CAn you post your new code


#5

ok, haha, now it works. I don't know what I was doing, many thank yous for your help!


#6

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