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

Noah Fields
Noah Fields
13,985 Points

Pound symbol not recognized or accepted

This exercise involved using the pound symbol (#), more commonly known as a hashtag. However, whenever I attempted to concatenate it (userName += '#') I got an error saying that step 1 was no longer passing. I tried it in Workspace, and, indeed, every time I tried to add a pound symbol on its own, anything involving the variable it was added to simply would not run (for instance, alert(username); would not do anything). Eventually I just went up to the "id" variable and added the pound symbol to the end of that - this worked, for whatever reason, but clearly was not the intended method to solve this problem. What is up with this particular symbol that makes it unusable on its own as a string? I tried it with a single letter ("d") and it worked fine so it's clearly not the fact that it's only one character.

1 Answer

Steven Parker
Steven Parker
231,269 Points

I don't think there's anything special about the "#" symbol. But this challenge is expecting only the first name (uppercased) for task 1, and both names uppercased and separated by "#" in task 2. Adding only the symbol to the end doesn't satisfy the requirements of either task and causes the check routine to consider that "step 1 is no longer passing".

This doesn't explain your workspace experience.. I would need to see the actual code from the workspace (prefereably in a snapshot) to comment on that.

:information_source: The symbol "#" by itself is not known as a "hashtag", but simply a "hash". An actual "hashtag" is a word or phrase preceded by a hash or pound sign (#) and used to identify messages on a specific topic on social media sites. It's not a word commonly used in regards to programming.

Noah Fields
Noah Fields
13,985 Points

I did actually add the last name to the code as well. It was just that, using Workspace, I tracked issue down to the hash symbol so that's what I focused on in my question. I should have been clearer.

Here's the Workspace code. I tested it again, just to be sure, and the same thing happened.

Also, thanks for telling me to use a snapshot. This is much nicer than copy/pasting large amounts of code into the comment, which I've done on a couple occasions previous.

Steven Parker
Steven Parker
231,269 Points

Yes, those snapshots are really handy for analysis.

So it turns out the problem is on line 11 of scripts.js where there is a reference to an undeclared variable "usernName" (with an extra "n", instead of "userName"), which causes a ReferenceError.

Also, in index.html on line 11 the script element which loads in the JavaScript code is inside the container div element, but it would normally be the last thing in the body.