6. We Made a Friend!


#1


Oops, try again. There was a problem with your syntax.

Can anyone help me with this? I couldn't figure out where is wrong :frowning:


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 contactLength = contacts.length;
    
    for(var i=0; i < contactLength; i++){
        if(contacts[i].lastName === lastName){
           printPerson(contacts[i]);
            }
        }
    
    };
    
  search("Jones");
  
  function add(firstName, lastName, email, phoneNumber){
      contacts[contacts.length] = {
          firstName : firstName,
          lastName : lastName,
          phoneNumber: phoneNumber;
          email: email
          };
      
      }
      
add ("Doggy","Bark","doggybark@ex.com","700-000-1234");
list();


#2

Your syntax error is in the add(firstName, lastName, email, phoneNumber) function. Take a look at where you're setting the phoneNumber value near the end. Do you see a fix you can implement?


#3

got it now.. . thank you so much to point it out!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.