Lesson 4 PLEASE HELP


#1

Hi,

this is my whole code:

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];
var printPerson = function (person){
console.log(person.firstName +" " + person.lastName);
console.log(person.firstName +" "+ person.lastName);
}
printPerson(contacts[0]);
printPerson(contacts[1]);

var list = function();
var contactsLength = contacts.length;
for (var i = 0; i< 2; i++){
console.log(printPerson(contacts[i]);
}
};

list();

and it doesn't work...can anyone please tell me why? I will be thankfull


#2

Ill tell you soon but can you can please format your code like this


#3
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];
var printPerson = function (person){
console.log(person.firstName +" " + person.lastName);
console.log(person.firstName +" "+ person.lastName);
}
printPerson(contacts[0]);
printPerson(contacts[1]);

var list = function();
var contactsLength = contacts.length;
for (var i = 0; i< 2; i++){
console.log(printPerson(contacts[i]);
}
};

list();

#4

@microwhiz52912
Hi, I saw a couple of minor errors and have highlighted the two lines:
1. where you just need to replace a semi-colon with a { curly bracket
2. add an additional ) closing bracketthe code

hope that helps

var list = function(){
// switch semi-colon ; to a { opening curly bracket

var contactsLength = contacts.length;
for (var i = 0; i< 2; i++){

// add an extra ) closing bracket
* console.log(printPerson(contacts[i]));

}
};

list();
`


#5
function list() {
    var contactsLength = contacts.length;
    for (var i = 0; i < contactsLength; i++){
        printPerson(contacts[i]);
    }
}

list();

#6

Hello
thanks for your answers, I did it few days ago..:)but thanks for your time.

Good luck!