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 trialBrian Schmitz
11,167 PointsSetting the "Greeting" Variable challenge
Can someone please take a look at my code here and let me know where I am missing in trying to set up the Greeting variable. Much appreciated. Thanks
var genericGreet = function(name, mood) { name = name || "you"; mood = mood || "good"; return "Hello " + name + ", my name is " + this.name + " and I am in a " + mood + " mood!"; }
var andrew = {
name: "Andrew"
function(name, mood) {
name = name || "you";
mood = mood || "good";
return "Hello " + name + ", my name is " + this.name +
" and I am in a " + mood + " mood!";
}
}
var args1 = ["Michael", "awesome", ":)"];
var greeting = genericGreet.greet.apply(andrew, args1);
1 Answer
notf0und
11,940 PointsYour variable "greeting" is wrong. Simply remove the ".greet" :)
var greeting = genericGreet.apply(andrew, args1);
Brian Schmitz
11,167 PointsBrian Schmitz
11,167 PointsThanks Bryan. How about this last challenge in the prototypes section where they want us to set the prototype's wheels to 4. Here is my code:
wheels = new Car (4);
notf0und
11,940 Pointsnotf0und
11,940 PointsLike so:
After setting "Car.prototype" to equal the object "carPrototype", the last line creates a new key of "wheels" and gives it the value of 4, inserting it into the object.
This is probably the most confusing part of JavaScript to get a grip on, so do some Googling and rewatch the videos :)