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 trialAlex Forseth
8,017 PointsHow do I add a # symbol?
how do I add a hash symbol to the 4th line variable?
I have been stuck on this for an hour.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase + lastName.upperCase();
lastName += "#";
<!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
Steven Parker
231,275 PointsYou can put the literal string in between the other the other variables and methods with an extra "+" symbol.
But also be careful of the method name spelling, and be sure to put parentheses after the method name "toUpperCase" to invoke (or "call") the method.
Alex Forseth
8,017 PointsSo now for some reason I get that task one needs to be done correctly. Seriously starting to lose it. Why was the below code not correct?
var id = "23188xtr"; var lastName = "Smith";
var userName = id.toUpperCase + "#"() + lastName.toUpperCase();
Jennifer Nordell
Treehouse TeacherHi there! Steven Parker mentioned that you need to be sure to include empty parentheses after the method you are calling. This is true. But you've gone a bit overboard and included an extra set of parentheses after something that is not a method: "#"()
. This is just regular string concatenation and needs no parentheses so it should look like: + "#" +
. Those extra parentheses are causing a syntax error. When a syntax error occurs your code can no longer be interpreted at all and thus, you will receive the "Task 1 is no longer passing" message. Which is true, because the part you previously did can no longer be interpreted.
It's the toUpperCase()
that's the method.
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Hope this helps!