Get stuck


#1



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


SyntaxError: Unexpected token {
Oops, try again. There was a problem with your syntax.


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 < (contacts.length - 1); i++) {
        printPerson(contacts[i]);
    }
}
list();


#2

even when you function doesn't have any parameters, you still need the brackets:

function list /* missing () */ {

it is part of the function syntax


#3

thx it helped me a lot but still not working
it is working with

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 < contacts.length; i++) {
        printPerson(contacts[i]);
    }
}
list();

but I think it doubles the returns so is not the correct way to pass this waypoint.


#4

why do you have:

< (contacts.length - 1);

no need for the minus one. As for the double output, it is the codecademy console (it seems codecademy calls your function again in the background), but as you can see here, that is just a codecademy thing