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 JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

How to apply .toUpperCase method on multiple variables?

How do I apply .toUpperCase method on multiple variables in one file?

app.js
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
id =+ "#"
id =+ "lastName"
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
231,248 Points

:point_right: It's probably easiest to do it while you initialize userName.

Something like this:

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

Thank you!!

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 27,696 Points

Another little tip: :fire: wrap all in parentheses and call the method once.

var userName = (id + '#' + lastName).toUpperCase();
Steven Parker
Steven Parker
231,248 Points

:x: This 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
Rich Donnellan
Treehouse Moderator 27,696 Points

Now that you mention it, I seem to remember that. 'Tis a shame, as this should be the preferred answer.

Trevor Johnson
Trevor Johnson
14,427 Points

Hi 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();