Finding that special someone


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


Oops, try again. You have the following error in your code: ReferenceError: i is not defined


4. Finding that special someone

Hi. Well you have issue with calling for list() function. You are trying to pass it a parameter contacts[i] when that function is not accepting any parameters.

You should be calling it with

// code 
// you have it like list(contacts[i]); instead

Fix that for start, and what you have will list all people inside contacts list.


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