6. We made a friend


ar 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++) {

/*Create a search function
then call it passing "Jones"*/
var search = function(lastName) {
var contactsLength = contacts.length
    for (i=0; i<contactsLength; i++){
    if (contacts[i].lastName === lastName) {

var add = function (firstName, lastName, phoneNumber, email) {
  var contact = {
    firstName: firstName,
    lastName: lastName,
    phoneNumber: phoneNumber,
    email: email
 contacts[contacts.length] = contact;
 add("Ariana", "Trafford", "555-555-5555", "arianatrafford@email.com")


My code works fine.... I am very confused on one line tho and am hoping someone can explain it to me.  Not sure if I forgot it or if it wasn't even covered.

What is the purpose of:

contacts[contacts.length] = contact;


What is the intention behind this topic?
If you're looking for help with something, then please make it abundantly clear what you want to know.


I am asking what is the purpose of the line:
contacts[contacts.length] = contact;


See how that's not visible without scrolling to the bottom of your code box? That's a problem!

That line stores a contact at the last index plus 1 in contacts


Sorry I just assumed you would want to see the code in its entirety.

Thank you for your reply