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

This question seems ambiguous.

I am a little lost here:

The question asks me to make the object use two keys: fiestName and lastName ... and delete the variable declaration.... also don't change anything in the console.log() call.

this leaves a few seemingly valid possibilities that I can think of, none of which will the test accept as the credited response.

If I declare the two keys under the contact function, the values will be under contact.firstName ..... and we will get a parse error because the reference wasn't changed in the console.log to this.firstname.

If I instead declare the keys within the function fulname, then it is giving me another error saying that the values for firstName were supposed to be a string, which they are. I have also tried it with '' quotes and "" quotes. I have tried seemingly every combination of ways this would work, but nothing is being credited as the correct answer.

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

I meant to say the contact object, not function.

2 Answers

Thank you. Hopefully they would be open to rewording the question in the future, as specifying whether they want these properties declared as contact.firstName... or contact.fullName.firstname ... could make the question clearer for us.

Definitely agree. This question is worded terribly.

Kevin Kenger
Kevin Kenger
32,834 Points

Hey David,

You're right, you would get an error. But the challenge just wants you to take it one step at a time; you'll fix the issue in the next step of the challenge. Try adding the two properties to the contact object as you said, and you should get an accepted answer.

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