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

I think this step has a bug. I type the .toUpperCase modifier for the varriables but get a failure alert.

I use a document.write function to inspect my work but that has no effect on the result. I also add the .toUpperCase to the individual variables like it says to do but that doesn't work. The code I've tagged here may help with solving my problem.

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

rydavim
rydavim
18,814 Points

Sometimes the challenges can be a little bit finicky about what you give them as your answer. I would try removing any extraneous code bits.

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();

I think that should do it, but let me know if it's still causing you problems.

the solution you provided worked, thanks for the help :D

var id = "23188xtr";
id.toUpperCase(); //not assigned to variable- remove
var lastName = "Smith";
lastName.toUpperCase(); //not assigned to variable- remove
var userName = id.toUpperCase() + '#' + lastName.toUpperCase(); //this is correct just have this as your answer
document.write (userName); //not asked to do in challenge- remove

One to remember is challenges are very fickle as to what they will accept.

the first question of the challenge is asking you to assign the variable of id to the variable username which you have, then to concat a # plus the var lastName, which you also have. all you need to do is to remove the above mentioned code and you should be good to go. Remember only do what the code challenge asks you to do. If not it will not let you pass the challenge. I hope this helps.

String.toUpperCase() will return an uppercase value but it won't change the original string if you do...

lastName.toUpperCase();

You can make it save the uppercase version by having the result overwrite the original variable like this...

lastName = lastName.toUpperCase();

Oh and here is the solution to the code challenge that worked for me.

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

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