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

David Dehghani
David Dehghani
6,992 Points

Adding variables..

I don't think I have this down quite right. Is there something I'm missing? Or am I doing this wrong?

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

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, and you're really close here. But they don't just want the id to be uppercase, they also want the lastName to be upper case. It seems like you might have missed that bit of the instructions. It is possible to do this all on one line of code. And because you are so close here, I'm going to just leave these hints. But if you're still stuck, please let me know! :sparkles:

David Dehghani
David Dehghani
6,992 Points

Argh, I'm so close I can taste it! I don't think I'm getting how to add both variables in one line to upper case.

This was my failed attempt:

var id = "23188xtr"; var lastName = "Smith";

var userName = id.toUpperCase() lastName.toUpperCase();

userName = id + "#" + lastName;

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Oh, still close! Take a look at how I did it.

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

This one line will take the id and uppercase it, then concatenate the pound sign/hash tag in the middle, then add the upper case version of lastName onto the end.

Good luck to you! :sparkles:

David Dehghani
David Dehghani
6,992 Points

Ah I see. I was making things more difficult for myself. Thanks for the help Jennifer! :)