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 Returning Values

Adalyn Ordono
Adalyn Ordono
828 Points

How do I return a string of values within an object's method?

I seem to be having syntax and parsing problems.

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

1 Answer

Steven Parker
Steven Parker
231,268 Points

You did the right thing converting the logging function into a return, but somehow in the process you lost the space that was being placed between the names as the final string is built.

:point_right: Try again, but be sure to return the same string that was being logged by the original code.

Adalyn Ordono
Adalyn Ordono
828 Points

Solved the challenge, thank you!