Think I found a bug that isn't supposed to be there


#1

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

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

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

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

So, when I did sayJob i got it correct but there was an error on the screen on the right When i did "Hi, I work as a " + sayJob" ??? Hopefully this will help the devs?
Uploading...


#2

You need to review sayJob() method, should be:

sayJob: function(work) {
   console.log("Hi, I work as a " + this.job);
}

So, instead of sayJob I used this.job to know what is the current job for james. So, now:

// james' first job
james.sayJob(); // prints "super programmer"

// change james' job to "super programmer" here 
// (but I changed to programmer because james is now a "super programmer")
james.job = "programmer";

// james' second job
james.sayJob(); // prints "programmer"

#3

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