4.Listing Everybody... Unexpected token


#1


4.Listing Everybody


I've read over this a few times and I can't find where there is the unexpected token.
Error message: Unexpected token )


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);
}

function list()
{
    var contactsLength = contacts.length;
    for( i= 0, i < contactsLength - 1 , i++)
    {
        printPerson(contacts[i]);
    }
}
list;


#2

for( i= 0, i < contactsLength - 1 , i++)

use ; instead of ,

and here

list; //wrong

call the function like

list();


#3

Wow ima fool ... Thanks a lot man !!!


#4

you are not fool :slight_smile:

mistake is good . because you'll learn from your mistake :slight_smile:


#5

I find the names are displayed twice, may I ask why?


#6

The lesson checker (SCT, Submission Correctness Test) runs our code in order to test it, so we see the output twice.generally you can ignore it.

you can print at the end
console.log("my code is end")

after this any code you see in the console just ignore it :slight_smile:


#7

Thanks, I thought it was because of my code.


#8

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