Listing Everybody SOLVED


#1

I seem to be having the same issue as others but cannot get it to work even when going through the suggestions in the similar threads.

' ' '
'var contacts = [bob, mary];

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

var list = function() {
var contactsLength = contacts.length;
for (var i = 0; i < contactsLength.length; i++) {
printPerson(contacts[i]);
console.log(printPerson(contacts[i]));
}
};
list();
' ' '
Error: looks like your list function didn't console.log "Bob Jones". Did you remember to call list(); after creating it?

It must be something so small as usual. And I'm not catching it.


#2

Your console.log is inside your "for loop". It should look like this.

var list = function() {

  var contactsLength = contacts.length;   

  for(i = 0; i < contactsLength; i++) {
      
        printPerson(contacts[i]);   

}

}
console.log(list());


#3

Actually you showed me another error that I overlooked. In my loop, I have i < contactsLength.length; for the condition. I fixed that too. I read too much into this instruction: "create a for loop that cycles from 0 up to one less than the number of items in the contacts array."

I fixed it. Yes the corrections work thank you.


#4

Thank you for the help


#5