4/6 Why is it only printing bob?


#1

I changed my code a couple of times but it is still incorrect. Usually I rewrite everything and that fixes the problem but I have don that already and still nothing, I've been stuck on it for a while now. Can someone please explain what I did wrong? I don't need the answer.

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


#2

Consider the difference between what it currently does and what you intend for it to do. You print once but want to print multiple times. What would cause it to print multiple times? Check if it's doing that something, check the things that need to happen for that difference to not be there.


#3

Thank you! I got it!
I think staring at it too long has made me not see it anymore!


#4

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