6/6 I`m sure that I wrote it right Why am I getting an error? SOLVED


#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 add(firstName, lastName, phoneBook, email) {
this.firstName = firstName;
this.lastName = lastName;
this.phoneBook = phoneBook;
this.email = email;
}

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) {
for (var i = 0; i < contacts.length; i++) {
if (lastName === contacts[i].lastName) {
printPerson(contacts[i]);
}
}
}
contacts.push(new add("Micle", "Kamael", "(650) 777-7777", "mary.johnson@example.com"));
list();


#2

Hi @codesurfer29202
Everything is fine, what's wrong ?


#3

Oops, try again. It looks like your new contact doesn't have a phoneNumber property.


#4

ok sry i know now what is wrong))) ahah stupid mistake = it has to be phoneNumber - i have phoneBook


#5

:sweat_smile: Fu**ing slight mistake