Error: Undefined


#1


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


Errors: "undefined"
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 = new Object();
mary.name = "Mary Johnson";
mary.phoneNumber = "(650) 888 - 8888";
mary.email = "mary.johnson@example.com";

var contacts = ["bob", "mary"];

console.log(contacts[1].phoneNumber);

Could someone enlighten me as to what's wrong with my code? TIA!


#2

this line:

var contacts = ["bob", "mary"];

bob and mary shouldn't be strings, they should be the objects names (so without the quotation marks (")), you can store objects into arrays


#3

Hello @weichunseah,

Instead of using

mary.name = "Mary Johnson"

split it into two categories, firstName and lastName and set each one individually... This should make it work...


#4

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