Whats wrong with my codes . any help please >?


#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 (fistName , 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

I think you got a typo on var add = function fistName? instead of firstName