4. Can I see your references? SyntaxError: Expected ')'


#1

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


SyntaxError: Expected ')'

I've checked everything and compared to other people's code but I can't figure it out. As far as I can tell (and I have refreshed the page before as well) nothing's wrong.

So obviously it's something tiny that my untrained-as-of-yet's eye is not able to pick up or something.


var james = {
    job: "programmer",
    married: false,
    sayJob: function() 
    {
       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

Hi @demtemblem,

Usually when you are coding you will be working with an editor that has a linter. A linter helps you find problems.

Go to https://repl.it/languages/javascript and paste your code in to see which line has the problem.

Let me know how you get on with that.


#3

Okay turns out that changing the sayJob console.log part from what I have in my Original Post to this

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

fixes it. Why? Why can't the below work?

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

EDIT: nevermind...I forgot a +...untrained eye....lol. Thanks for the link to that linter thing tho that'll be helpful! :slight_smile:


#4

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