Listing Everybody


#1

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

SyntaxError: missing ) after argument list
Oops, try again. There was a problem with your syntax.

I've looked at other codes as well as my own and I don't see what's wrong. There are too many ways to do the same thing and I'm really confused. Please help.


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


#2

It says a ) is missing so it'll probably be near a ( right?

There are many combinations, it would be pointless to try to make things "click". Instead we have to compare how things differ to what we expect, that usually says a lot about what change is called for.


#3

When you call your function within the loop remember the syntax.
ie. call the function by just typing the function's name, and putting a parameter value inside parentheses after it.
like this: functionName(parameter value).

I hope this helps you.


#4

Instead of console.logging it within the for loop, you are required to call the earlier 'printPerson' function, using the index of the contacts as an argument, like so:

for (var i = 0, i < contacts.length, i++) {
printPerson(contacts[i]);
}
};

Trying seeing if it makes any difference.


#5

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