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 trialAlexandria Hamlett
4,179 Pointsvar 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".
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
var userName
<!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
231,248 PointsThat 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é
23,204 PointsHi 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é
23,204 PointsNope, 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
231,248 PointsI 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é
23,204 PointsI 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
23,494 PointsFirst create a var to concatenate the 3 items (id, "#", lastName):
var string = id + "#" + lastName;
Then you can uppercase var string
Steven Parker
231,248 PointsThat 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!