Exercise 1.4 - Can I See Your References?


#1



https://www.codecademy.com/courses/objects-ii/0/4?curriculum_id=506324b3a7dffd00020bf661


My code passes, but I receive this error message:

"ReferenceError: 'job' is undefined"


var james = {
    job: "programmer",
    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.sayJob("super programmer");

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

I don't understand 1) why it passed with the error message, and 2) what needs to be done so the console will print the messages.


#2

1) The submission test might have found everything it was looking for, or maybe it failed to take care of the exception that you're raising and crashed itself.

2) If something is not defined and you're using it, then you'll need to define it or use something else. Ask yourself what you're trying to access and where/how you can get that.


#3

1.when you call the function, it has to have a parameter (the job)
so -- sayJob: function (job){......
2. you have to replace "[job]" with "this.job"
3. in change james job to "super programmer" is
james.job="super programmer"

Notice you are changing the line 2 with this metido.

the code:

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

sayJob: function(job) {
    // 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();


#4

Olá, após algumas verificações, segue o código executado:

var james = {
job: "programador",
married: false,
sayJob: function() {
console.log("Oi, sou um" + " " + this.job);

}

};

// primeiro emprego de james
james.sayJob();

// mude o emprego de james para "super programador" aqui
james.Job ="super programador";

// segundo emprego de james
james.sayJob();