We've Made a Friend!


#1

"Make sure that the list() function still exists! Your code threw the following error when checking if you called list(): Error: Line 49: Unexpected token ILLEGAL"

I keep getting this error message despite the code printing the correct list of people including the newly added contact, what's going wrong?


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

function add(firstName, lastName, email, phoneNumber) {
    contacts[contacts.length] = {
    firstName: firstName,
    lastName: lastName,
    email: email,
    phoneNumber: phoneNumber,
    };
};

add("Naomi", "Bayliss", "njb@email.com", 075634729000);

list();


#2

Line 49 is where I call the add function for those wondering


#3

Your phone number just needs to be in quotation marks! :smiley:


#4

Perfect! Thank you! :smile:


#5

No problem! :smiley: Happy coding!

P.S. you have an extremely long phone number :stuck_out_tongue:


#6

07   => country code (Kazakhstan)
563  => area code
472  => prefix
9000 => number

#7

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