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

Mark Bernard
Mark Bernard
2,746 Points

.toUpperCase seems to be changing all strings.

Trying to complete this challenge but I keep getting this error message.

The userName variable is "23188xtrSmith" not "23188XTR#SMITH".

Not sure what is going wrong.

I have also tried to add the .toUpperCase property in the var id on line 1 and in the final var on line 4, I just get the same message?

app.js
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase();
var 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! I like that you've tried different things and told us what they are! That is always appreciated and ultimately makes a better experience for you. On your 3rd line, you are using the toUpperCase() on id, which is what you're supposed to do. But that result isn't saved anywhere. It's sort of floating out there in JavaScript limbo.

On your final line you have the id and the last name concatenated together. But again, that upper case version of id wasn't saved anywhere so it's accessing the original value in id which is still all lower case. I do not see anywhere that you've turned the last name to uppercase which is also a requirement. Between the uppercase id and the uppercase lastName, you will also need to concatenate a '#'. I feel like many people get thrown off this, but there is nothing really special about this character at all. It's just another character like any other.

The first step you obviously figured out. You make a variable named userName and assign it the uppercase version of id.

Finally, add a # symbol and lastName in uppercase to the end of the userName string.

So let's break it down.

Add a # symbol.

var userName = id.toUpperCase() + "#";
// the value will now be 23188XTR#

Add the lastName in uppercase:

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
// the value will now be 23188XTR#SMITH

Hope this helps! :sparkles:

Note: you can safely delete line 3 as it ultimately does nothing.

Mark Bernard
Mark Bernard
2,746 Points

Thank you. I think the problem was that I was misunderstanding the fundamental question and what it was asking of me.