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 trialCarlton Whittaker
1,995 Pointsvar 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?
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + var lastName.toUpperCase();
<!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>
Marcus Parsons
15,719 PointsThe 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.
Jacob Mishkin
23,118 Pointsthe # 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
Marcus Parsons
15,719 PointsHey 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();
Carlton Whittaker
1,995 PointsThank you all for your replies to my question, that's one more piece of Javascript I now know :)
Thomas Clark
571 PointsIn 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
Daniel Stockham
10,277 PointsDaniel Stockham
10,277 PointsI'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.