Introduction to Object-II


#1



https://discuss.codecademy.com/c/javascript/objects-ii

whats the solution ?its keep on saying syntax error?
i dont think so there is any syntax error.

var james = {
    // add properties to this object!
    james.job:"programmer",
    james.married:false
    
};



function Person(job, married)
{
    this.job = job;
    this.married = married;
}

// create a "gabby" object using the Person constructor!
var gabby = new Person("student", true);


#2

There are two ways to create objects with properties and you combined both, which is incorrect.

For literal notation you should write it like this:

var james = {
   job: "programmer",
   married: false
};

Usually you use this when your object must have a set of properties defined at the start.

For dot notation you write it like this:

var james = new Object();
james.job = "programmer";
james.married = false;

Dot notation is commonly used to access and create/modify properties along the way. You can start by creating the empty object first, then assigning or modifying properties. You can also use it after you've created an object via literal notation.


#3

Thanks a lot its working.
:stuck_out_tongue_winking_eye: