6- we made a friend


#1

var contacts = [bob, mary];

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

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

/*Create a search function
then call it passing "Jones"*/
function search(lastName){
var contactsLength = contacts.length;
for(i=0; i if(printPerson(contacts[i])= lastName){
printPerson(contacts[i]);
}else{

    }
}

}
search("Jones");
function add( firstName, lastName, email, phoneNumber){
var adam= new Object();
}
add("Adam","Sanders","■■■■@mofo.com", "(333)-33-3333");
list();

this gives an error- invalid Left ahnd side in assignment(line 33)


#2

Hi inside your function add( firstName, lastName, email, phoneNumber){ "here" } it should be like the example they give you on top of the instruction wich is like that

contacts[contacts.length] = {
    firstName: firstName,
    lastName: lastName,
    phoneNumber: phoneNumber,
    email: email
}

#3

Hi there! in your add function, it should define and store the values firstName, lastName etc. you when you call the function inside the contacts list. So it should look something like this:

function add(firstName, lastName, email, phoneNumber){
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
}
}

add("Adam", "Sanders", ■■■■@mofo.com, "(333)-33-3333")
list();


#4

function add(firstName,lastName,phoneNumber,email){
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
}
}
console.log(contacts.length);
add("a","b","c","12345");
list();

Above code is throwing me an error saying: It looks like you didn't log "a b" to the console. Did you remember to call list() after adding your new contact?
What am I missing?Please suggest


#5

I solved it by myself. thanks


#6

bonjour , comment vous avez fait?


#7

I'm having the same problem. How did you solve it?