Oops, try again. Make sure that the list() function still exists!


#1

6 We made a friend

Receiving this error message, but haven't changed list function....
Oops, try again. Make sure that the list() function still exists! Your code threw the following error when checking if you called list(): Error: Line 51: Unexpected token ILLEGAL


Replace this line with your 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 (lastName===contacts[i].lastName) {
printPerson(contacts[i]);
}
else {
console.log("No results found!");
} 
}
}
    
  

 function add(firstName,lastName, phoneNumber, email) {
    
   contacts[contacts.length] = {
       firstName: firstName,
       lastName:lastName,
       phoneNumber:phoneNumber,
       email:email
   };
 }
add("Jo","Bloggs",07898765,"bitby@free.fr");

   
   list();


#2

this line:

add("Jo","Bloggs",07898765,"bitby@free.fr");

and then specificly the phonen umber:

07898765

the sequence of numbers you picked seemed to be a problem, try:

`add("Jo", "Bloggs", 12345, "bitby@free.fr")

#3

Thanks... have spent hours going over everything


#4

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