6.we made a friend



ReferenceError: 'add' is undefined
Oops, try again. Did you create a function called add?

please help me, I cant find the problem

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

/*Create a search function
then call it passing "Jones"*/

function search(lastName){
    var contactsLength=contacts.length;
    for (x=0; x<contactsLength; x++){
        if (search===lastName){
var add=function(firstName, lastName, email, phoneNumber){
        firstName: firstName,
        lastName: lastName,
        email: email, 
        phoneNumber: phoneNumber
add("darrell", "walker","afnh@aol.com", 123-123-1234);


Move the last '}' to close above the function, because you are nesting the add function within the search function. It should close the search function.


thank you so much, it worked like a charm


Here's my code as an extra reference too.

Its fully working.

Hope it helps.



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