We Made a Friend! Help!


#1

https://www.codecademy.com/courses/building-an-address-book/0/6?curriculum_id=506324b3a7dffd00020bf661

Please if anyone can tell me what syntaxError I am making here? I got error msg of "SyntaxError: Unexpected identifier". Thank you !!

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

/*Create a search function
then call it passing "Jones"*/
var search = function(lastName) {
    var contactsLength = contacts[i];
    for (var i=0; i<contacts.length; i++) {
        if (contacts[i].lastName === lastName) {
            printPerson(contacts[i]);
        }
    }
}


var Add = function (firstName, lastName, phoneNumber, email) {
    this.firstName = firstName;
    this.lastName = lastName;
    this.phoneNumber = phoneNumber;
    this.email = email;
}

contacts[contacts.length] = {
    var amanda = new Add ("Amanda", "Orange", "415-8881888", "orange@hotmail.com")
}

list();


#2

function was not declared properly.


#3

hmm.. that did not solve it..


#4

uhm okay..... you made some errors in your code

this should be inside your add function.

Commas are supposed to be Used not semi colons.

Colons are supposed to be use also instead of the equals sign

And you have to call the function alone, like this

Instead of attaching to a variable


#5

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