Can I see your references? (How does this work?)


#1

The code passes but in the window I get
"TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined"

How is it that this works? I've fought with this for a while because everything I've looked at that runs correctly is said to be "Wrong" or "Impractical". I tried using "[job]" as it is the same as .job, because .job didn't work. Everything I've seen for this exercise that works seems to be quite off the path that the directions would lead you on. You seemingly can't leave the argument blank but any arguments that work are impractical? What would seemingly be the best answer for this exercise? and also why is it that my code passed but left the error in the window?

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.sayJob("super programmer");

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


#2

job is in the same context as the method, sayJob() so the method needs no parameter.

sayJob: function () {

}

this.job is the james object context of job.

That brings us to this line...

.job is a property that we may set directly. We would not change it using the sayJob method. It is not a setter.

james.job = "super programmer"

#3

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