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
Pascal B.
6,673 PointsCode challenge: Objects Methods problem ?
HI,
The question of this code challenge is: On 'andrew' and 'ryan', set the 'greet' method as the 'genericGreet' function.
There seems to be no explanation in the video on how to achieve that. I tried alot of things and nothing works. What i'm doing wrong ?
Here's the code of my last attempt:
<script>
var genericGreet = function() {
return "Hello, my name is " + this.name;
}
var andrew = {
name: "Andrew"
greet: genericGreet
}
var ryan = {
name: "Ryan"
greet: genericGreet
}
Thanks !
1 Answer
ryanloerzel
12,671 PointsHi Pascal,
I had the same problem. You need to add a comma between each object attribute:
var genericGreet = function() {
return "Hello, my name is " + this.name;
}
var andrew = {
name: "Andrew",
greet: genericGreet
}
var ryan = {
name: "Ryan",
greet: genericGreet
}
Pascal B.
6,673 PointsPascal B.
6,673 PointsThank you so much Ryan !!!