Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Foundations Objects Call and Apply

Lamyaa Khamlichi
Lamyaa Khamlichi
10,978 Points

Attempting to mimic code for Objects - Call and Apply

I have copied this code from the Objects - Call and Apply lesson but I keep getting the following error: Uncaught ReferenceError: Invalid left-hand side in assignment. It says this is at line 10 which is the console.log("Hello, " + name +

Where have I gone wrong?

var jim = { 
    name: "Jim", 
    skills: ["Javascript", "HTML", "CSS"],
    "favourite color": "green",
    greet: function (name, mood) {
        name = name || "You";   
        mood = mood || "good";  
        console.log("Hello, " + name +
                    "I am " + this.name +
                    " and I am in a " + mood = " mood!");
    }
};

jim.greet();

1 Answer

This is the problematic part:

" and I am in a " + mood = " mood!"); 

That = should be a +.

Lamyaa Khamlichi
Lamyaa Khamlichi
10,978 Points

Oh yes, stands out a mile now, thanks!