3. Adding your friends


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/3?curriculum_id=506324b3a7dffd00020bf661#

It is saying there is a syntax error and I'm not sure where or how can you please explain?


var friends =  new Object();
bill:{
    firstName:"Bill",
    lastName:"Gates",
    phoneNumber:"(480)-123-4567'
},
steve:{
   firstName:"Steve",
    lastName:"Jobs",
    phoneNumber:"(480)-890-1234'
}
},


#2

Hi these lines

phoneNumber:"(480)-123-4567'
phoneNumber:"(480)-890-1234'

you should use " " or ' ' you can't use " '


#3

I did and they still aren't working what now?
var friends = new Object();
bill:{
firstName:"Bill",
lastName:"Gates",
phoneNumber:"(480)-123-4567"
},
steve:{
firstName:"Steve",
lastName:"Jobs",
phoneNumber:"(480)-890-1234"
}
},


#4

you got 2 way to do object

Object constructors

var friends = new Object();

to add an other object inisde friends you do it like that

var friends = new Object();
//bill
friends.bill = new Object();
friends.bill.firstName: "Bill";
.....

//steve
friends.steve = new = Object();
friends.steve.firstName = "Steve";

or an object literal

var friends = {
   bill : {

    },
    steve : {

    }
}

#5

Here is my new code
var friends = new Object();
friends.bill = new Object();
friends.bill.firstName: "Bill";
phoneNumber:"(480)-123-4567"
},
friends.steve = new = Object();
friends.steve.firstName = "Steve";
phoneNumber:"(480)-890-1234"
},
It still says there is a syntax error what now?


#6

Hi first remov all the { } in your code then this line

friends.steve = new = Object();

you have more = than you doyou know which one?

If not

if not its the one after new

then here

friends.bill.firstName: "Bill";
phoneNumber:"(480)-123-4567"

you should change the : with = the same here

phoneNumber:"(480)-890-1234"

#7

Here is my new code
var friends = new Object();
friends.bill = new Object();
friends.bill.firstName= "Bill";
phoneNumber="(480)-123-4567"
friends.steve.firstName = "Steve";
phoneNumber="(480)-890-1234"

Now it is asking if I put Steve as a friend what now?


#8

if you made the change I mention on my last post your code should be like that

var friends = new Object();

friends.bill = new Object();
friends.bill.firstName = "Bill";
phoneNumber = "(480)-123-4567"

friends.steve = new  Object();
friends.steve.firstName = "Steve";
phoneNumber = "(480)-890-1234"

and look a your new code

var friends = new Object();

friends.bill = new Object();
friends.bill.firstName= "Bill";
phoneNumber="(480)-123-4567"

//it missing friends.steve = new  Object();
friends.steve.firstName = "Steve";
phoneNumber ="(480)-890-1234"

#9

YES!!! It works thanks bro. :grin: