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

Ben Esther
Ben Esther
881 Points

I still can't figure out this challenge

In this challenge I am supposed to use the JavaScript .toUpperCase() to assign an uppercase id variable to the userName variable. However, when I do this I get a message saying "Bummer! The 'userName' variable is '(insert uppercase id, I can't remember it off the top of my head)', not (insert uppercase id) #SMITH" I suspect that there is something wrong with this challenge as I have already done concatination and am currently on functions, but if I am doing something wrong, what should I do to fix it?

Thanks, Ben Esther

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

Steven Parker
Steven Parker
231,269 Points

Don't forget to store the result in the variable.

Most methods (and certainly the string case conversion ones) don't actually change the thing you call them on. So you need to put the result somewhere.

So this code creates an uppercase version of "id" but then puts the original value of "id" into the new variable:

id.toUpperCase();
var userName = id;

But with a slight rearrangement, the upper case version is put into the new variable instead:

var userName = id.toUpperCase();
Ben Esther
Ben Esther
881 Points

```var id = "23188xtr";

var lastName = "Smith";

var userName = id.toUpperCase();

userName += '#' + lastName.toUpperCase;```

Thanks for your help. However, when I enter this code for the 2nd part of the challenge it says 'Oops! It looks like step 1 is no longer passing!''

Steven Parker
Steven Parker
231,269 Points

It looks like you forgot the parentheses in your second call to toUpperCase().