11. Creating a new object


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-9Sgpi/2/3?curriculum_id=506324b3a7dffd00020bf661

There was a problem with your syntax.

...

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


#2

Hi it's missing the comma after this line

type: 'fancy'

#3

Did you create your object using the object constructor?

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


#4

you should
create a object using the object constructor
in the introdution of the course they show you how to create one ...


#5

example please :slight_smile:


#6

Here
When you use the (Object) constructor, the syntax looks like this:

var myObj = new Object();

This tells JavaScript: "I want you to make me a new thing, and I want that thing to be an Object.

You can add keys to your object after you've created it in two ways:

myObj["name"] = "Charlie";
myObj.name = "Charlie";

#7

i still dont understand


#8

Well you can create a object like that

var  me = {
    name: "Wiz" ,
    surname: "Marco"
};

and this syntax is called object literal notation
-----
OR you can create a Object constructor so your object will be like that

var me = new Object();
me["name"] = "Wiz";
me["surname"]  = "Marco";

it's the same object just the syntax is diff.


#10

im still stumped :cry: :cry:


#11

i figured it out

var me = new Object();
me.name = "Jasmine"
me.age = 15

:joy: :joy: :joy: :joy: :joy: :joy:


#12

good job. I'm stuck on the same part


#13

Still, or have you solved it?


#14

I solved it with me brain


#15