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

Methods challenge

Boy, do I suck at Javascript.

Anyways, this is what I have, it's saying no.

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

      var andrew = {
        this.name: "Andrew"
        gerericgreet: function() {
             console.log("Hello, I am " + this.name);
      }

      var ryan = {
        name: "Ryan"
        gerericgreet: function() {
             console.log("Hello, I am " + this.name);
      }

Help?

1 Answer

First of all, you don't need this.name: in the andrew object, you just need name:.

Second, you don't have to write the function, you already have it — genericGreet. All you have to do is add a new property to the objects called greet and point it to the function like this:

var myObject = {
   someProperty: "something",
   newProperty: genericFunction
}