What's wrong? 6/6


#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"*/
var search = function(lastName){
var contactsLength = contacts.length
for (var i = 0; i < contactsLength; i++) {
if(lastName === contacts[i].lastName){
console.log(printPerson(contacts[i]));
} else {
console.log("You are out of names or you don't have any friends like that");
}
};
};

var add = function (firstName, lastName, email, phoneNumber) {
contacts[constact.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
};
};
add("Ole", "Andson", "exemple@hotmail.com", "0762028");

list();


#2

never mind the problem was contacts[constact.length] it should be --> contacts[contacts.length]


#3

@tagjumper20201..

try it out....
function search(lastName){
var find = contacts.length;
for (var i = 0;i < find;i++) {
if (contacts.lastName === find[i])
{
printPerson(contacts[i]);
return (contacts[i])
}
}
}
search("jones");
I hope it helped....