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

Eric Kidwell
Eric Kidwell
12,327 Points

Stage 6 Objects > Methods Code Challenge

I've tried about 10 different ideas and I have a feeling it's just something silly that I'm missing. Please help!

It's asking : "on 'andrew' and 'ryan', set the 'greet' method as the 'genericGreet' function.

Here's where I'm at now

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

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

      var ryan = {
        name: "Ryan"
        greet: genericGreet
      };
Daniel Dropik
Daniel Dropik
705 Points

Out of curiosity, why is it incorrect to say:

greet: genericGreet()

or

greet: genericGreet();

Eric Kidwell
Eric Kidwell
12,327 Points

It's because of the parentheses :D They're not needed.

2 Answers

comma

Eric Kidwell
Eric Kidwell
12,327 Points

Wow, I think that signifies that it's time for bed. Thanks :)

Molly Dopheide
Molly Dopheide
11,083 Points

if it helps I did the same thing. I kept thinking 'why is the greeting: not turning green?'