[resolved]4. Adding properties


#1
var friends = {
    
    bill : {
        firstName: 'Bill',
        lastName: 'Clinton',
        number: '555-5555'
    },
    
    steve : {
        firstName: 'Steve',
        lastName: 'Jobs',
        number: '888-8888'
    }
    
};

var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();

I have a message :
Oops, try again. It looks like your friends don't have the firstName property.

My first props is firstName :dizzy_face:


#2

You made them with the property, then deleted everything. Why you do that?


#3

My first attempt , I forgot commas. As I am not sure on me, I decided to start over. It 's past midnight in France , I admit that fatigue makes me do anything. :tired_face:

The syntax looks good, but I still have the same message. I don't understand my error(s).


#4

I realized my mistake when I woke up this morning. I wrote twice objects. :sweat_smile:


#5

This is a solution:

var friends = {
bill :{
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555"
},
steve:{
firstName: "Steve",
lastName: "Jobs",
number: "(206) 555-5555"}
};


#6

Thank you a lot Herrera. I have finish before your message.

My problem was between my chair and my screen :stuck_out_tongue:

I have wrote two object and I waste with three last line :

var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();

The objects "friends.bill" and "friends.steve" are empty properties so the above objects become empty and exercise back to not write anything at all in objects.

It is intended that this Cadecode say in his message.

var friends = new Object();
friends.bill = new Object('Bill', 'Clinton', '555-5555');
friends.steve = new Object('Steve', 'Jobs', '888-8888');

also works