Adding properties


#1

Hi, everybody! Need your help, please. Smth is going wrong I couldn't figure out.
Output is SyntaxError: Expected ';'
var friends = new Object();

friends.bill = new Object();
firstName: "Bill",
lastName: "Gates",
number:"(352) 351618";

friends.steve = new Object();
firstName: "Steve",
lastName: "Jobs",
number:"(352) 981189";

friends.aliakbar = new Object();
firstName: "Aliakbar",
lastName: "Gofurov",
number:"(352) 586489";

friends.eldor = new Object();
firstName: "Eldor",
lastName: "Abbozov",
number:"(960) 837352";


#2

Well you try to mix object and constructor notation. Inside an object you pair keys and values by

key:value,

but outside of the object you assign values to properties by using object.property = value.


#3

so what you are doing is mixing the 2 ways of doing an object but you don´t do it correctly.
if i´m not mistaken
if you want to use
>>>friends.eldor = new Object();<<<then you need to do >>> friends.eldor.firstName = Eldor;

but it is much easier to just do it like this:
friends.eldor = {firstName:Eldor,}
I would do this method for the whole problem instead of using the new Object()


#4

thank you for your advice