10. Object Syntax


Guys i need help here understanding what am doing wrong.
I will think i have everything right but kept getting error message

var me = {
    name = 'Ambrose';
    age = 38

Error message:

SyntaxError: Unexpected token 

Oops, try again. There was a problem with your syntax.


Hi this line

name = 'Ambrose'; <--

you should change the ; with a comma


I used that and it is giving me the error message below:

SyntaxError: Invalid shorthand property initializer


you have to use : instead of =

Literal notation is just creating an object with curly braces, like this:

var myObj = {
    type: 'fancy',
    disposition: 'sunny'


Thanks Mate.
Got it now.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.