5. Finding that Special Someone (Syntax Error)


#1



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"*/
function search(lastName) {
    contactsLength = contacts.length;
    for( i = 0; i < contactsLength; i++) {
        if(lastName === contacts[i].lastName) {
            printPerson(contacts[i]);
        } else {
            console.log("Contact not found!");
    }
}
search("Jones");

This print out : SyntaxError: Unexpected end of input
What did I miss or do wrong?


#2

Check you brackets. Generally that error means you have to many or to few. Looks like you need 1 more closing bracket.

Hope this helps @r4z0r244


#3

lol cant believe this, I really did need one more bracket! thanks for the help.


#4

No pro! We've all made that mistake before :slight_smile: