Problem with the syntax


#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]);
}
}

var search = function(lastName) {
var contactsLength = contacts.length;
for (var i = 0; < contactLength; i++) {
if (contacts[i].lastName = search) {
printPerson(contacts[i].lastName);
}
}
};
search("Jones");

var add = function (firstName, lastName, email, phoneNumber) {
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
email: email,
phoneNumber: phoneNumber
};
};
add("This", "That", "hehe@lolol.com", "555-465-9871");
list();

it gives me a problem with the syntax, please help


6/6 We made a friend!
#2

Your 'search' function's 'for' statement is missing the left hand side of the comparison. Then your following 'if' statement's equality comparison is attempting assignment ('=' instead of '===').

In the future, please provide the exact error and a link to your lesson.


#3

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