6. We Made A Friend Syntax Error


#1

Hi I thank you for taking the time to look at this I can;t find the error.
SyntaxError: missing) after argument list

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 contactsLength = contacts.length;
for (var i = 0; i < contactsLength; i++) {
if(lastName === contacts[i].lastName) {
printPerson(contacts[i]);

var add = function(firstName,lastName,email,phoneNumber) {
add(Isis,Curiel,curielisis16@gmail.com,219-671-6463)

};
};
};
};

list()


#2

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

var add = function(firstName,lastName,email,phoneNumber) {
add(Isis,Curiel,curielisis16@gmail.com,219-671-6463) 
//You're calling the function inside itself, instead of writing any code it can use
};
//add(Isis, Curiel, curielisis16@gmail.com,219-671-6463); //move that line here!
}; //Not all closing brackets " } " need a semi-colon " ; " These hurt your code
};// <-/   |
};// <-----/

#3

You're missing a lot of code, there's a lot of syntax errors because of it.

  1. Your search function should be on it's own
  2. Your add function is missing the statement that adds a new array
  3. Your calling your add function inside your add function.

Try the lesson over again, make sure to re-crete your search function then create a new add function. After that call the add function.

Without helping you out too much here is some info to get you on the right track:

var contactsLength = contacts.length;

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

var add = function(firstName,lastName,email,phoneNumber) {
            ***** YOU NEED TO CREATE THIS ******
    };
};

add("Isis", "Curiel", "curielisis16@gmail.com", "219-671-6463");

list();