Totally stuck on "More People"


#1

This is my 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"];
console.log(contacts[1].phoneNumber);

The console shows "undefined" and the lesson states "Oops, try again. Make sure that mary is the second object in contacts".

When I try console.log(contacts[1]); I get "mary", but when I add .phoneNumber I always get "undefined", for either bob or mary. What is the proper way to call a property in an array?


#2

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};
My working code below.

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888 - 8888",
email: "mary.johnson@example.com"
};

var contacts = [bob,mary];
console.log(mary.phoneNumber);


#3

This code worked for me


#4

Ahh, it was the quotes around bob and mary in the array. Thanks!


#5

This code worked for me also ...