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

Tucker Humiston
Tucker Humiston
1,025 Points

javascript strings problem

Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".

Is it just something small I am forgetting to put in?

app.js
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase(userName);
var userName = id + "#" + lastName;
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>
Bogdan Martinescu
Bogdan Martinescu
6,030 Points

You need to remove line 3 and place before document.write :

userName = userName.toUpperCase();
Tucker Humiston
Tucker Humiston
1,025 Points

I changed the code to this but it doesn't work.

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

Bogdan Martinescu
Bogdan Martinescu
6,030 Points

The code should be, as described above:

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

the toUpperCase needs to be after you declared the variable, so just switch lines 3 and 4

2 Answers

your really close on this all you need to do is concatenate the variables and the string into one variable. like this:

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

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

and there you go. Happy coding.

Not a problem! any time.