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 trialThomas Katalenas
11,033 Pointsadd this to the method with property values.
At first onset the question appears to be relatively easy, however the implementation I found was a cascade of property nesting within the method declaration. As a way to circumvent "this", I used property values of first and last name above the method so as to maintain stack call ordering. The question I keep having is there another way to do this. And I also have a syntax error, can you find it?
var contact = {
firstName : "Andrew";
lastName : "Chalkley";
fullName: function() {
this.firstname;
this.lastName;
// console.log(firstName + " " + lastName);
}
}
2 Answers
Steven Parker
231,268 PointsYour object properties should be separated with commas, not semicolons.
Then, the contents of the function should look something like this:
console.log(this.firstName + " " + this.lastName);
Thomas Katalenas
11,033 Pointsvar contact = {
fullName: function() {
firstName : "Andrew",
lastName : "Chalkley"
console.log(this.firstName + " " + this.lastName);
}
}
still did not work
Thomas Katalenas
11,033 PointsThomas Katalenas
11,033 PointsThe code above is incorrect, could someone point me in the right direction.