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 trialDavid Thrower
6,693 PointsThis 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.
var contact = {
fullName: function() {
firstName: "Andrew";
lastName: "Chalkley";
console.log(firstName + " " + lastName);
}
}
2 Answers
David Thrower
6,693 PointsThank 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.
John Perry
Full Stack JavaScript Techdegree Graduate 41,012 PointsDefinitely agree. This question is worded terribly.
Kevin Kenger
32,834 PointsHey 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);
}
}
David Thrower
6,693 PointsDavid Thrower
6,693 PointsI meant to say the contact object, not function.