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 trialEthan Bagley
5,044 PointsSet the "greet" method
Challenge: set the 'greet' method as the 'genericGreet' function.
I added the following line:
greet: genericGreet ();
... but that isn't working. Any tips?
3 Answers
Erik McClintock
45,783 PointsEthan,
This is a common (thus, very easy to make) mistake: in the line of code that you wrote, you're CALLING the method by adding the parenthesis at the end. If you want to set it as a value instead, simply omit the ( ) from the end (as well as the semi-colon, since you're inside an object) and you'll be good to go.
var andrew = {
name: "Andrew",
greet: genericGreet
}
Erik
Ethan Bagley
5,044 PointsThanks Erik. I dropped the parentheses in subsequent tries, but not the semi-colons... appreciate the clarification!
Erik McClintock
45,783 PointsFor sure! Glad I could help clear things up :)
Erik