You made a friend: syntax error


Hi All,

I am struggling with the 'Add' bit of this exercise. Any help much appreciated.

I am getting the message: "SyntaxError: Unexpected token :"

var bob = {
    firstName: "Bob",
    lastName: "Jones",
    phoneNumber: "(650) 777-7777",
    email: ""

var mary = {
    firstName: "Mary",
    lastName: "Johnson",
    phoneNumber: "(650) 888-8888",
    email: ""
var contacts = [bob, mary];
function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);
var add = function(firstName,lastName,email,phoneNumber) {
    this.firstName: firstName,
    this.lastName: lastName, email,
    this.phoneNumber: phoneNumber
contacts[contacts.length] = add;
function list() {
	var contactsLength = contacts.length;
	for (var i = 0; i < contactsLength; i+=1) {


For starters, where is your "search"function>?


Hi Kat

I deleted the search function as suggested in the instructions, as I didn't think I needed it to make the 'Add' function work?



Wrong search function, The search function they wanted you to delete was the search("Jones"); one. Not the huge search function. Without it, the program will not function properly.


Oops, my bad.

I've added it back in but I'm still getting "SyntaxError: Unexpected token :"

Is there anything else that you can see might be wrong?

Thanks again, Joe.


Hi Joe,

I did the same thing as you did using the THIS keyword on my first try, and it didn't work.

var add = function (firstName,lastName,email,phoneNumber) {

// #1. Make a new object to hold the values WITHIN the function
var newContact = new Object();
newContact.firstName = firstName;
newContact.lastName = lastName; = email;
newContact.phoneNumber = phoneNumber;

// #2. Add the new object to the array -- also WITHIN the function
contacts[contacts.length]= newContact;

// 3. Now each time you call the function, it will create new object and add it to the array


hi guys! I found the instructions for this portion quite unclear but this is what I came up with. I think this is what they wanted. seems to work ???

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


you actually do not need the search function for this section to work. i deleted the entire function as well