Contact List: Adding Properties


#1

ERROR MESSAGE: "Oops, try again. It looks like your friends don't have the firstName property.

It does however send everything to the console. I don't know what it may be....

var friends = new Object();

friends.jose = new Object();
friends.firstName = "Jose";
friends.lastName = "Leal";
friends.number = "555-555-5555";
friends.address = ["1917 W Sunrise Boise, ID 83705"];
console.log(friends["firstName"]);
console.log(friends["lastName"]);
console.log(friends["number"]);
console.log(friends["address"]);

friends.steve = new Object();
friends.firstName = "Steve";
friends.lastName = "Jobs";
friends.number = "(208)111-2222";
friends.color = "brown";
console.log(friends["firstName"]);
console.log(friends["lastName"]);
console.log(friends["number"]);
console.log(friends["address"]);

friends.bill = new Object();
friends.firstName = "Bill";
friends.lastName = "Gates";
friends.number = "208-599-2222";
friends.address = ["789 West Dr, Carmel, CA 94420"];
console.log(friends["firstName"]);
console.log(friends["lastName"]);
console.log(friends["number"]);
console.log(friends["address"]);


Replace this line with your code.


#2

@joselealjr

You are not assigning any value to your new Object Jose or Bill

Right, first, you set jose as a new object from friends object.

But then, you are assigning value to the properties of friends object not jose object.


#3

i guess im lost then...

would it be:

friends.jose.fristName = "Jose";
friends.jose.lastName = "Leal";
friends.jose.number = "555-555-5555";

???


#4

@joselealjr

No!!!

Instead do it like this:

jose.firstName = "Jose";
jose.firstName = "Leal";
// etc

Don't put friends in front because we know it already belongs to friends object.


#5

ahhh!!

wow, it makes a lot of sense now to me!!
I really do appreciate your help!
:slight_smile: