6. We Made A Friend..Am I right?


#1

Hi,

I've done the whole task with a bit of help from the forum. Anyway, I was hoping someone could just check to see if I am right, and that I'm not missing anything or have anything that is not necessary.
Thanks

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

function search(lastName) {
    var contactsLength = contacts.length;
    for (var i = 0; i < contacts.length; i++) {
     if (contacts[i].lastName === lastName) {
         printPerson(contacts[i]);
     }
    }
};
search("Jones");

function add(firstName, lastName, email, phoneNumber) {
    contacts[contacts.length] = {
 firstName: firstName,
 lastName: lastName,
 email: email,
 phoneNumber: phoneNumber
    };
};
add("Bruce", "Wayne", "@hotmail.com", "12345");
list();


#2

@satty10,
It looks good.... :heavy_check_mark: