Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Objects Methods

Abdurashid Mahad Isse
Abdurashid Mahad Isse
7,062 Points

please somebody help me with this...

https://teamtreehouse.com/library/methods-3

index.html
<!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>
Erik Krieg
Erik Krieg
43,038 Points

Have you tried anything for this challenge yet? If you have, we can do over what you wrote.

1 Answer

      // The question is asking you to add this method(function) below to the objects 'andrew' and 'ryan'
      var genericGreet = function() {
        return "Hello, my name is " + this.name;
      }

      //Andrew has the property "name" and we want to add another property "greet". Set the value of it. 
      var andrew = {
        name: "Andrew"
        //Add a new property. 
        /* Seperate multiple properties with a comma. The last one should not have one. 
            propertyName: propertyValue, 
            propertyName: propertyValue,
            propertyName: propertyValue
       */
      }

      var ryan = {
        name: "Ryan"
      }