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

Katie Boster
Katie Boster
1,606 Points

This is what I'm typing : var userName = "id#lastName".toUpperCase(); The code should result with 23188XTR#SMITH

Unable to move forward with the last question to the string variables.

app.js
var id = "23188xtr";
var lastName = "Smith";

var userName = "id#lastName".toUpperCase();
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>

4 Answers

Abe Layee
Abe Layee
8,378 Points

You're combining the var the wrong way. We use the + sign. By adding quote around the variable, it become a string not a variable anymore.

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

you need to break that up into chunks. the first part asks you to change id to all upper case. so you would use

var userName = id.toUpperCase();

then in the second part you already have the id to uppercase so you just need to add the # and the lastName. so like this

userName += "#" + lastName.toUpperCase();

just remember everytime you add to the var userName it changes it to what you just put into that variable.

hope this helps and happy coding.

Hi Katie, You're close. You just need to call the toUpperCase on each of the variables and use string concatenation to add the '#' then assign it all to the userName variable.

for example:

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Katie Boster
Katie Boster
1,606 Points

Thank you everyone. This really helps!