Lesson 5


#1

var friends = new Object ();

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


var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    }
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-JOBS",
        address: ['Jobs House', 'Jobs City']
};

Having some issues with syntax according to the error message. I would love an explanation to anything I am missing here. Thanks ahead of time :smile:


#2

it would seem that you're trying to make subclasses to the friends object twice.

remove this:

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

and you should be good to go.


#3

still have a error with the following...

var friends = new Object ();



var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    }
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-JOBS",
        address: ['Jobs House', 'Jobs City']
};

#4

Sorr also get rid of the other friends object.

var friends = new Object ();

#5

Now have a unexpected identifier error.. :stuck_out_tongue:


#6

Last correction:

    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-JOBS",
        address: ['Jobs House', 'Jobs City']
    //missing closing bracket
};

#7

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    }
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-JOBS",
        address: ['Jobs House', 'Jobs City']
}
};

Still getting a error :0


#8

Alright, I feel pretty dumb.

 bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    } //Add a comma after this closing bracket

#9

like this? Still getting a error. And don't feel dumb, I am the with the wrong code :stuck_out_tongue:

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
    },
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-JOBS",
        address: ['Jobs House', 'Jobs City']
}
};

#10

Correct, did that fix your error?


#11

No, it did not :stuck_out_tongue:


#12

I'm quite newb, but shouldn't there be a comma between end of number and beginning of address? Like this:


#13

we have a winner!! Thanks so much. Newb or not you saved me a headache


#14

Thats great! Glad I could spot that in your code. Now if only I could do the same in my own more often.... :stuck_out_tongue:


#15

what is wrong ??

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way','Redmond','WA','98052']
    }
    steve: {
        firstName: "Steve",
        lastName: "Jobes",
        number: "(206) 555-5555",
        address: ['One Apple Way','Greenmond','CA','14910']
        }
};

unexpected identifier


#16

Please format your post as I have done (select entire code block; press Ctrl+Shift+C) from next time. Thanks! :smile:

Hint: You are missing commas on line 5 and 7


#17

Thanks Gaurangtandon finaly I got the solution.