Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

var id = "23188xtr"; var lastName = "Smith"; var userName = id.toUpperCase(); var userName what is wrong with this

Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".

app.js
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase(); 
var userName 
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>

3 Answers

Steven Parker
Steven Parker
215,987 Points

That last line is not a complete statement.

Plus, you don't want to declare a variable more than once. But you can add to a variable using the add assignment operator ("+="), like this:

userName += more_stuff_you_want_to_add_on_the_end;
Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,202 Points

Hi Alexandria,

Your close, but remember what they are asking: Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".

Currently your code is stopping and outputting "23188XTR"

To complete the rest of the task you need to concat a # and the lastName using the same .toUpperCase();

See below one example of how to do this:

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,202 Points

Nope, if you look under the heading for the question: they clearly state Task2 Steven. But thank you—I know you where pointing that out in good intention. ?

Steven Parker
Steven Parker
215,987 Points

I think people generally have a better learning experience when they complete something themselves using a few hints rather than being shown a final solution.

Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,202 Points

I agree, Steven. I hate when people just give you the answer. I try to facilitate people as best I can — hence the explanation above my code, and not just the answer.

Nick Escobedo
Nick Escobedo
23,494 Points

First create a var to concatenate the 3 items (id, "#", lastName):

var string = id + "#" + lastName;

Then you can uppercase var string

Steven Parker
Steven Parker
215,987 Points

:x: That actually doesn't work on this challenge. It's a sound idea code-wise, but the challenge wants to see this done a certain way. Follow the instructions!