Object 2:-Can I See Your References?


#1

var james = {
this.job: "programmer",
this.married: false,
sayJob: function() {
// complete this method
console.log("Hi, I work as a [job]");
}
};

// james' first job
james.sayJob();

// change james' job to "super programmer" here
james.job="super programmer"

// james' second job
james.sayJob();


#2

what is the problem
with this code ....it says( unexpected token .)


#3

Hello @vigneshpunniam,

You have to console.log() james' job to concatenating "Hi, I work as a " and this.job. Hope this fixes your problem...


#4

var james = {
this.job: "programmer",
this.married: false,
sayJob: function() {
// complete this method
console.log("Hi, I work as a "+this.job);
}
};

// james' first job
james.sayJob();

// change james' job to "super programmer" here
james.job="super programmer"

// james' second job
james.sayJob();

like this ah


#5

what is wrong with this program


#6

You don't need to add the property this.job into an object. Change this.job and this.married to job and married respectively, and your code should work fine!


#7

Remove this. from Line 2 & 3 // you are not defining a method, you are defining keys
Add a semi-colon at the end of Line 14 i.e. james.job="super programmer"

hope this help


#8

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