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 JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

I don't know how to make the final value of userName be "23188XTR#SMITH"

So I'm supposed to complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. The final value of userName is supposed to be "23188XTR#SMITH".

var id = "23188xtr"; var lastName = "Smith"; var userName = id.toUpperCase();

This is where I'm getting confused. I've watched the video twice and I still have no idea :(

var userName = "id.toUpperCase" + "lastName.toUpperCase"; id += "#";

1 Answer

Tim Larson
seal-mask
.a{fill-rule:evenodd;}techdegree
Tim Larson
Full Stack JavaScript Techdegree Student 13,696 Points

Hi Bianca!

Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".

Using string concatenation is the key here, and it basically means to "add on" or "combine" strings. Applied to your code it would mean that you would be combining the string values held by your "id" and "lastName" variables, and assigning it to the new var userName. so you wouldn't need to call them with quotation marks. Also, the challenge only needs the "#" as an additional string value held by var userName between your id and lastName variables. Hopefully this works for you!

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();

Thanks so much Tim!!