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 Object-Oriented JavaScript (2015) Introduction to Methods Understanding this

How do I modify the object so it uses two two properties?

This is a challenge from the "Understanding This" portion of Object Oriented JavaScript.

object.js
var contact = {
  contact.firstName : ["Andrew"],
  contact.lastName : ["Chalkley"]
  fullName: function() {
    console.log(firstName + " " + lastName);
  }
}

I just figured it out!!!! Sorry to bother... LOL

Grace Kelly
Grace Kelly
33,990 Points

awesome stuff!! never apologize for reaching out for help and congrats on figuring it out on your own :)

1 Answer

Grace Kelly
Grace Kelly
33,990 Points

Hi Janette, you've got the right idea apart from a couple of things, you have given each property an array by using '[]' in order to assign a single value to an object's property we do this:

var contact = {

firstName : "Andrew"

}

Note the syntax of the property and how it differs from the variable syntax, you do not need to add contact. before it as you are declaring these properties within the contact object :) So by applying this syntax to your code you should be on the right track and don't forget to add a comma after each property apart from the last one, which i can see you have done already :)

Hope that helps!!