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

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.