6/6 We made a friend



I'm finding it difficult to complete exercise 6. When I submit my code this error message appears

"Oops, try again. Make sure that the list() function still exists! Your code threw the following error when checking if you called list(): TypeError: Cannot read property 'hasOwnProperty' of undefined"


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++) {

/*Create a search function
then call it passing "Jones"*/

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

var add = function (firstName, lastName, email, phoneNumber) {
    contacts[contacts.length] = {
        firstName: firstName,
        lastName: lastName,
        email: email, 
        phoneNumber: phoneNumber, 
add("Anne", "Smith", "anne@email.com", "333-323-333");


You might try a refresh Browser

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser


Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


Thanks! I took your advice and refreshed the browser before I submitted my code.


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