6/6 I need help!


#1

Hi! could somebody figure out what is wrong with this code?

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; i < contactsLength; i++) {
if (contacts[i].lastName === lastName) {
printPerson(contacts[i])
};
};

};

search("Jones")

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

add("David","Williams","(404) 666-6666","abc@gmail.com");
list();

SyntaxError: expected expression, got '='


#2

try:
function add(firstName,lastName,phoneNumber,email){ //01
contacts[contacts.length] = {
firstName: firstName,
lastName: lastName,
phoneNumber: phoneNumber,
email: email
};
};


#3

Sorry, that didn't work for me. I can't figure out what's wrong.


#4

Never mind I copied it wrong, Thanks for your help!!!