What I must write here?


#1

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);
}

var list = function(XXXXXXXXXXXXXXX){
var contactsLength = contacts.length;
for(printPerson = 0;printPerson < contactsLength.length; printPerson++);
};

list(XXXXXXXXXXXXXXX);


#2

Which exercise you are mentioning again?


#3

We'll be creating a function that lists all of the users.

Create a function called list that does not take any parameters.
At the start of the function, define a variable to store the number of items in the contacts array. Call it contactsLength.
All of the items in an array are numbered, starting at 0. To cycle through all of the elements of the array, create a for loop that cycles from 0 up to one less than the number of items in the contacts array.
Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
At the very bottom of the file, call the list function. The list function should then loop through every member of the contacts array and print its information.


#4

Building an Address Book

Listing Everybody


#5

1. Create a function called list that does not take any parameters. So it should not have anything.

var list = function()

2. At the start of the function, define a variable to store the number of items in the contacts array. Call it contactsLength.

var contactsLength = contacts.length;

3. All of the items in an array are numbered, starting at 0. To cycle through all of the elements of the array, create a for loop that cycles from 0 up to one less than the number of items in the contacts array.

for ( i = 0; i< contactsLength; i++)

Do not use a function name (printPerson) for looping. You have used printPerson which is not correct as it is a function you have used earlier. You have already put the contacts.length in a variable called contactsLength, so you do not need to use contacts.length again just the contactsLength. And that's the whole point of doing step 2.

4.Inside of the loop, add code to call printPerson, passing in the element of the array that the loop is currently at.
{
printPerson(contacts[i]);
}
5. At the very bottom of the file, call the list function.
list();

Altogether what you must write here:

var list = function(){

var contactsLength = contacts.length;

for( i= 0;  i< contactsLength; i++)   [do not use semicolon here, for loop is not finished here]
{
    printPerson(contacts[i]);
}
};

list();

Try to give a weblink of the exercise which you are having problem with. It is easier and faster to find out.


#6

Thank you very muc. it worked