5/6 Syntax: Unexpected Identifier Error


#1

I am usually able to spot my mistakes after a few minutes of reviewing. For some reason the issue in this part is eluding me. Can anyone help me find the unexpected identifier?

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


#2

The error is on this line

if contacts[i].lastName === lastName {

should be

if( contacts[i].lastName === lastName) {

#3

@brandon_thimmesch,
The condition of an IF-statement is always encapsulated in a pair of parentheses-( )


#4

Oh wow, can't believe I missed that. Thank you.