This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by pgtc2009
almost 11 years

It passed but there is SyntaxError: missing : after property id

Is this still right? This is my code: var james = { // add properties to this object! job: “programmer”, married === false

};

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

// create a “gabby” object using the Person constructor! var gabby = new Person(){ job: “student”, married === true }

Answer 5260107bf10c605228000e6a

8 votes

Permalink

try this one

var james = { // add properties to this object! job: “programmer”, 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);

points
Submitted by Manish Kumar
over 10 years

1 comments

jscazzola over 9 years

Thanks

Answer 51d2fae39c4e9d2adc00e4e3

4 votes

Permalink

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

I guess this line gives you the error message:

married === false

which means compare married to false. But what you should do is give james a property married like you did it for job and make this property equal to false:

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

And for the constructor:

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

well this.job and this.married are public properties of the later created object, which will get their values by the parameters of the function so if you create a new object via the constructor it goes like this:

var gabby = new Person("student", true)

in this case you just need to provide the parameters, no need to add an object literal.

points
Submitted by haxor789
over 10 years

Answer 52e9710e282ae3418a000b59

0 votes

Permalink

Then after the gabby constructor gabby.job = “student” gabby.married= true // you put in the correct syntax :)

points
Submitted by Dangdude
about 10 years

Answer 555a162e937676468e000303

0 votes

Permalink

The correct one

var james = { // add properties to this object! job:”programmer” , married:false

};

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

// create a “gabby” object using the Person constructor!

var gabby=new Person() { gabby.job=”student”; gabby.married=true; }

points
Submitted by sim_m
almost 9 years