Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Objects Methods

JS Objects and Functions

I need help with this challenge task. I can't quite figure out what the task wants me to do

3 Answers

Eddie Solar
Eddie Solar
20,455 Points

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

  var andrew = {
    name: "Andrew",
    method: value(function to be called)
  }

  var ryan = {
    name: "Ryan",
    method: value(function to be called)
  }
Jacob Miller
Jacob Miller
12,466 Points

andrew and ryan are both javascript objects. genericGreet is a function. Methods are functions contained in an object that can be called on the object. To complete the challenge, you need to create a new method called greet in each of the objects, andrew and ryan, and give that method the value of genericGreet. Make sure you add a comma after the first property. Example below:

var objectName = {
    property: value,
    method: value
}

Thanks to both of you, I already figured it out though a few minutes after this post.