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 trialNora Rossini
1,039 PointsHow to apply .toUpperCase method on multiple variables?
How do I apply .toUpperCase method on multiple variables in one file?
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
id =+ "#"
id =+ "lastName"
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 PointsIt's probably easiest to do it while you initialize userName.
Something like this:
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Rich Donnellan
Treehouse Moderator 27,696 PointsAnother little tip: wrap all in parentheses and call the method once.
var userName = (id + '#' + lastName).toUpperCase();
Steven Parker
231,248 PointsThis is not a valid answer for this challenge.
I specifically did not mention it in my answer because while it would work in actual code, the challenge will not accept it as an answer.
Give it a try yourself and see
Nora Rossini — this should probably not be a "best answer" since it does not work with the challenge.
Rich Donnellan
Treehouse Moderator 27,696 PointsNow that you mention it, I seem to remember that. 'Tis a shame, as this should be the preferred answer.
Trevor Johnson
14,427 PointsHi Nora,
You are trying to add the # and the lastName variable to the id instead of adding both of those to the username that you made all uppercase. You can also add them to userName at the same time. One last issue is that you need to use += when adding to a variable instead of =+.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
userName += "#" + lastName.toUpperCase();
Nora Rossini
1,039 PointsNora Rossini
1,039 PointsThank you!!