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 trialLangelihle Chimanya
7,176 PointsFinally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "231
im lost
var id = "23188xtr";
var lastName = "Smith";
var userName= "string"
<!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>
1 Answer
Ryan Dudley
Treehouse Project ReviewerHello Langelihle Chimanya! Hopefully I can help clear this up and get you on your way.
Currently, you are setting the userName
variable to a string literal that holds the value of "string". However, the challenge wants you to use the toUpperCase()
method on the id
variable, and store that information in userName
.
Step 1: Use the JavaScript .toUpperCase( )
string method to assign an all uppercase version of the id variable to the userName variable. We can accomplish this like so:
var userName = id.toUpperCase(); // userName now holds the value of '23188XTR'
The toUpperCase()
method is saying, convert the string contained within id
to all uppercase and store the resulting string in the userName
variable.
Step 2: Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH". There are a few different ways you could combine these strings, in this example I will just use the +=
and +
operators to concatenate the desired strings to the end of the userName
variable like so:
userName += '#' + lastName.toUpperCase(); // userName now holds the desired '23188XTR#SMITH' string.
In the above example, the +=
operator is saying add # + lastName.toUpperCase()
to the value already contained within our userName
variable. This means that the userName
variable now holds the desired string of 23188XTR#SMITH
I hope this was able to help you out, and if you are still unclear on how this works or need additional help do not hesitate to ask!
Sirena Escobedo
3,593 PointsSirena Escobedo
3,593 PointsThankyou! for posting your answer it definitely help me I was stuck on it for two days.