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 trialMicheal Emerson
8,207 PointsStuck on returning values challenge
Instead of logging out the full name, modify the code so it returns the string instead. Started with:
console.log(this.firstName + " " + this.lastName);
I changed it to the current code:
return "fullName";
Not sure what is wrong!
var contact = {
firstName: "Andrew",
lastName: "Chalkley",
fullName: function(){
console.log(this.firstName + " " + this.lastName);
}
}
2 Answers
Colton Ehrman
Courses Plus Student 5,859 PointsSo for this you will need to return something using return You had the right idea with console.log() but instead of logging it, you need to return what you where going to log.
console.log(this.firstName + " " + this.lastName);
Tommy Gebru
30,164 PointsHow can we call .log methods? Using the example below:
var contact = {
firstName: "Andrew",
lastName: "Chalkley",
fullName: function(){
console.log(this.firstName + " " + this.lastName);
}
}
Micheal Emerson
8,207 PointsMicheal Emerson
8,207 PointsThanks Colton!