10. Object Syntax


#1


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.


#2

Hi this line

name = 'Ambrose'; <--

you should change the ; with a comma


#3

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

SyntaxError: Invalid shorthand property initializer


#4

you have to use : instead of =

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

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

#5

Thanks Mate.
Got it now.


#6

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