6/6 It looks like you didn't log "Nemanja Sipka" to the console. Did you remember to call list() after adding your new contact?


#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];
var contactsLength = contacts.length;

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

function list() {

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

}

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

}

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

};

add("Nemanja","Sipka","(021)750-9311","juke_box_live@hotmail.com");
list();


#2

Nice job, your code helped me a lot.
You basically have it.

you just need to change:
list(); into list(contacts);


#3

@koala_t list(); is correct, you don't need the array, because the array is in the list function.

function list() {

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

}

@digitalslayer64788
this should be shorter and without a variable.

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