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 Methods

This is confusing

I am not sure exactly what to do in this case. It is telling me to set the greet method as the generic greet function. So do I assign the greet method to the generic greet variable?

3 Answers

Hi Damien,

andrew and ryan already have a name property with a name set. The challenge wants you to add the greet method to both and set it to the genericGreet function

var andrew = {
        name: "Andrew",
        greet: // set the generic greet function here
      }

 var ryan = {
        name: "Ryan",
        greet: // set the generic greet function here
      }

Hi Damien, here is what you should have.

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

      var andrew = {
          name: "Andrew",
          greet: genericGreet
      }

      var ryan = {
          name: "Ryan",
          greet: genericGreet
      }

Thanks guys. I was able to figure it out. Thanks for your reply.