4. Can I See Your References? / missing } after property list


#1

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

I can't see what's wrong with my code even though I've ran through all the other posts concerning this exercise. I get a message: SyntaxError: missing } after property list


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();


#2

Oops! Looks like you forgot to add a comma between your married and sayJob properties:

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

married: false <---- missing comma
sayJob: function(job) {

You also added a semi-colon that doesn't belong there:

sayJob: function(job) {
    // complete this method
    console.log("Hi, I work as a" + this.job);
};  <----**delete the semi-colon**

There's one more thing that is off about your code, even though it will work fine. Can you figure out what and why that it is?

the function call:
james.sayJob();
the function:
sayJob: function(job) {


#3

And plus to what @myssandria said, you need a space after 'a' in the console log so it will print it right (as you can see a space after the 'a':

 // complete this method
        console.log("Hi, I work as a " + this.job);

or you can do sapce by saying:

 // complete this method
     console.log("Hi, I work as a" + " " + this.job);

#4

Thanks for your quick replies. I've added the comma and space and deleted the semi-colon.

Is it the fact that the function takes the parameter (job)?
Should it rather be: sayJob: function() {?
Anyway, my code still doesn't run :stuck_out_tongue: :wink:
The error is: SyntaxError: missing ) after argument list

my code once again:
var james = {
job: "programmer",
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();


#5

You got it!

    job: "programmer",
    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();

Looks like you fixed everything, but you forgot a very important operator: the concatenation operator (+). It was on your original post, my post, and @funct1on's post, but it isn't on your fixed code:

console.log("Hi, I work as a " this.job);


#6

It did work this time :relaxed: Indeed, I forgot about the operator, so simple, yet so hard to see on your own sometimes! :wink: Thanks once again!


#7

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