2.More People. code prints, still get error message


#1


https://www.codecademy.com/courses/building-an-address-book/0/2?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. Make sure that mary is the second object in contacts


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 = new Array();
    contacts[0] = "bob"
    contacts[1] = "mary"
    console.log(mary.phoneNumber);


#2

Your contacts array stores only two names - "mary" and "bob". Names, nothing more. This contacts list would be pretty useless, don't you think? It would be nice to be able to retrieve e-mail address or a phone number.


In this exercise, you were supposed to create array of objects, not array of strings.

We can't do something like this:

"mary".phoneNumber

because "mary" is just a string, but we can do:

mary.phoneNumber

In the contacts array you should store objects - mary and bob.


#3

Thank you, I see now and have passed!
LO


#4

You're very welcome :slight_smile:


#5

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