Listing Everybody - Error


#1

Hi,

could someone please take a look at my code?

This is the message I get: Oops, try again. It looks like your list function didn't console.log "Bob Jones". Did you remember to call list(); after creating it?

... @^@

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; i ++) {
console.log(printPerson([i]));
}
}

list();


#2

try this instead of your part: printPerson(contacts[i]);
and after that remove the list(); at the bottom of your code


#3

Thank you, it worked. ✧٩(ˊωˋ*)و✧


#4

var contacts = [bob, mary];

function printPerson(person) {
console.log(person.firstName + " " + person.lastName);
}

function list() {
var contactsLength = contacts;
for (var x = 0; x < contactsLength; x++) {
printPerson(contacts[x]);
}
}

list();

Pretty frustrating - running into the same error but still can't figure out where the issue is coming from. Can someone help?