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

I'm working on the Full-Stack JavaScript Track, and I'm stuck, and for the life of me can't figure out the solution.

This is the question that I'm stuck on:

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".

Can someone help me out with the coding for it? I'm not sure which coding syntax to use to solve it. I keep wracking my brain, but can't come up with the answer.

2 Answers

Hi Carmelo,

I'm assuming you got to stage 2 of the challenge, so you know to use the .toUpperCase() method on id. After that, you'll just want to use the concatenation operator (+), to combine the userName string with "#" and with lastName, also converted to uppercase. It could be written as:

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

or more succinctly:

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

Also, for faster and more relevant help in future, it makes it a lot easier for the community to offer advice if you ask the question using the "Help" button on the code challenge, so we can gather context of what video/challenge/quiz you are stuck on.

Thank you both for your help, and I'll be sure to do that next time Benjamin. I appreciate the help.