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

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

I finally figured out the answer but could somebody remind me what's the purpose of the # symbol?

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

var userName = id.toUpperCase() + '#' + var lastName.toUpperCase();
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>
Daniel Stockham
Daniel Stockham
10,277 Points

I'm going to give an educated guess and state that the hash doesn't have a coding purpose. However, the hash does universally identify that any time an entity has an unique set of numbers, it has a "#" in it's field.

The hash could signal a separator between id's and last names so that you program an easy piece of code to split id's and user names up.

the # in the code is a string. Its purpose is to be a string in between the variable id and the variable lastName. Daniel and Marcus are right.

2 Answers

Hey Carlton,

All you have to do is remove the var keyword before lastName in the userName creation. The first var you use in the first lastName initializes the variable. You don't have to use var after that because you can't use it like this in the middle of concatenation and if you did it again, you'd be making a completely new variable:

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

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

Thank you all for your replies to my question, that's one more piece of Javascript I now know :)

Thomas Clark
Thomas Clark
571 Points

In repl.it, this work. Not sure why it's not working in TreeHouse.

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

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

userName + '#' + lastName