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

Nick Lohr
Nick Lohr
2,973 Points

Having trouble with Method Objective. "On 'andrew' and 'ryan', set the 'greet' method as the 'genericGreet' function."

I'm having trouble getting past this. Any help would be greatly appreciated! This is the exact question: "On 'andrew' and 'ryan', set the 'greet' method as the 'genericGreet' function."

and here is the code:

var genericGreet = function() { return "Hello, my name is " + this.name; }

var andrew = { name: "Andrew" }

var ryan = { name: "Ryan" }

Mike Bronner
Mike Bronner
16,395 Points

Please post a link to the challenge. That will help us work through it as well. :)

3 Answers

Mike Bronner
Mike Bronner
16,395 Points

Thanks for the link. So, you see the andrew and ryan objects already have two properties established: their names. Now you need to establish a second property for each, called greet, that points to the genericGreet function. Keep in mind when referencing functions or methods in JavaScript, that you leave the parentheses off. :)

I didn't want to give the solution away, but this should get you there. Let me know how you fare on this. :) Good luck!

Nick Lohr
Nick Lohr
2,973 Points

Cool thank you I got it now!

Mike Bronner
Mike Bronner
16,395 Points

Excellent! Glad to be of help. :)