Whats wrong?


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

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 (var i = 0; i < contactsLength; i++) {
if (contacts[i].lastName === lastName){
printPerson(contacts[i]);
}
}
};
search("Jones");

var add = function (firstName , lastName ,email ,phoneNumber){
this.firstName = firstName ;
this.lastName = lastName ;
this.email =email ;
this.phoneNumber = phoneNumber;
contacts[contacts.length]= new add ("mark" , "dibe" , "easy@hotmail.com" , "0096176781199");
}
list( );


#2

your add function's last line looks wrong. You need to create an object with the passed information, then add that object to your contacts list. Try something like this in your add function:

var object = {
(info)
};
contacts[contacts.length] = object;