Any help to fix this with explanation of my faults >?


var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: ""

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: ""

var contacts = [bob, mary];

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

var list = function (){
var contactlength = contacts;
for (var i=0 ; i printPerson(i);


your for loop is bad, really bad. the for loop has 3 parts:
for(init counter; test counter; increment counter). your init counter is good (var i = 0). then you should get test counter (i < contactlength) then you should increase the counter (i++), then inside you for loop call your printPerson function.

From the exercise:
Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.

You haven't done that at all, you called: console.log(list());, that simple isn't going to work


Your text has certainly been truncated because of the "<" sign of your loop. Since I don't know your real code, here's what I can say :

1) "var contactlength = contacts;". Your variable won't contain the number of contacts.
Do that : "var contactlength.length;"

2) "for (var i=0 ; i printPerson(i);". You didn't set the stop condition and the incrementation for you loop.
Do that : "for (var i = 0 ; i < contactlength ; i++){..."

3) "console.log(list());". You console.log is outside of the loop. Plus, the loop is not closed.
The whole function :

function list() {
var contactlength = contacts.length;
for (var i = 0 ; i < contactlength ; i++){

Don't forget to call your 'list()' fonction after that


@stetim94 i've just did my for loop just like u said , but i don't know its been consoled like that .
but thanks for the console.log notation