11. Creating a new object



There was a problem with your syntax.


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


Hi it's missing the comma after this line

type: 'fancy'


Did you create your object using the object constructor?

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


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


example please :slight_smile:


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";


i still dont understand


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.


im still stumped :cry: :cry:


i figured it out

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

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


good job. I'm stuck on the same part


Still, or have you solved it?


I solved it with me brain