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

genericGreet function

I seem to having some trouble getting past this code challenge. there is a variable set up as var genericGreet = function() { return "Hello, my name is " + this.name; }

then there are two objects with names, andrew and ryan. I have assigned them each a key:value pair that is identical:

    greet: genericGreet

I have tried this with parenthesis after or without and I can't seem to avoid the syntax problem/parse error. I even tried calling them each afterwords like such:

   ryan.greet()
   andrew.greet()

any help would be appreciated. thanks!

1 Answer

Calvin Nix
Calvin Nix
43,828 Points

Hey Liam,

Are you remembering to separate each key:value pair with commas?

e.g.

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