Codecademy Object Project: Address Book Answer

/*
Michael Le (username: mikele)
Codecademy Answer / Source Code
Object Project
Objects in address books are fun!
*/
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);
}
//1.4
function list(){
    var numItems=contacts.length;
    for(i=0;i<numItems;i++){
        printPerson(contacts[i]);
    }
}

//1.5
function search(lastName){
    var numItems=contacts.length;
    for(i=0;i<numItems;i++){
        if(contacts[i].lastName===lastName)
            printPerson(contacts[i]);
    }
}

//1.6 function
function add(firstName, lastName, email, telephone){
    //add newPerson object
    var newPerson ={
        firstName: firstName,
        lastName: lastName,
        
        email: email,
        phoneNumber: telephone
    };
    //add object to array
    contacts[contacts.length] = newPerson;
    
}

//1.4 run
list();

//1.5 run
search("Jones");

//1.6 run
add(prompt("first"),prompt("last"),prompt("email"),prompt("tele"));