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

how to answer this challenge

cant answer this

7 Answers

Michelle Cannito
Michelle Cannito
8,992 Points

It might help if you rewatch the video. Trying to recall syntax and answer, but I think it is this:

var andrew { 

  name: Andrew

  greet: genericGreet

}

Add the same greet: genericGreet line for Ryan. If it doesn't work, add () after genericGreet.

this is the original question, i have done a lot of trials but always wrong. help thanks challenge : On 'andrew' and 'ryan', set the 'greet' method as the 'genericGreet' function.

<!DOCTYPE html> <html lang="en"> <head> <title> JavaScript Foundations: Objects</title> <style> html { background: #FAFAFA; font-family: sans-serif; } </style> </head> <body> <h1>JavaScript Foundations</h1> <h2>Objects: Methods</h2> <script>

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

  var andrew = {
    name: "Andrew"
  }

  var ryan = {
    name: "Ryan"
  }

</script>

</body> </html>

how about asking a question, and showing us code.

Michelle Cannito
Michelle Cannito
8,992 Points

You have to add a method to within the curly braces of var andrew. The name of the method is greet. That greet method has to call the genericGreet function. Do the same for Ryan. Enough hints for you to get it now?

thank you Michelle, thats what im doing, pls have a look:

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

  greet:"genericGreet";

  var andrew = {
    name: "Andrew"
    andrew.greet()
  }

  var ryan = {
    name: "Ryan"
    ryan.greet()
  }

thanks michelle, are u from Manila

Michelle Cannito
Michelle Cannito
8,992 Points

You're welcome Marck! Strange guess. I'm from New York City and now reside in the San Francisco metro area. Fortunately for me, there are a lot of IT positions out here. I'm hoping to learn enough to get into the apprentice.io bootcamp. Intermediate level Rails is required. They pay $500/week while an apprentice, then help with job placement. Where are you from, and what's your goal?

lol... :) coz ur surname sounds like your from Manila Phils, Im originally from there, but now Im here in Sydney AU. I got IT background specially Networking - Cisco, IBM System X, Blade and etch. but that was more than 4 yrs ago, now I'am would like to be Apps developer android and IoS, but ultimately i wanna be experts in Front End and Back end Web Development, I just Wish we have 34 hrs/a day.. lol :)

Wow. Good for you.. I Pray for your success.. keep in touch... and can i ask a question, How much do you charge your friend for Building him a Website??

  • Static website 4 pages with Maintenance included (Photography Sites)
  • not included Hosting and Domain. $300 would be generous right?