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 - Using String Methods // Question

Hi all!

I'm sorry for posting a similar question to this post:

but I don't quite get WHY am I supposed to type "#" in the first place ?

====================

Question:

Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName variable.

My Answer:

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

var userName = (id + lastName).toUpperCase();
document.write(userName);

why am i supposed to write it this way ?

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

2 Answers

Hi Igor! If you get stuck, ask us bravely! First step, save id.toUpperCase() value in the userName. Now userName value equal to "23188XTR". Second step, use this on the other variable or add it to the userName variable. Last step, between id and lastName add to the "#" symbol.

You wrote this:

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

By the way, your solution is good, but

var userName = id + lastName.toUpperCase();
document.write(userName);

Don't use brackets and if I remember good don't use document.write, just save the value inside the userName. If you don't use the output is 23188xtrSMITH. You need to add it separately.

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

Hope this help.

I figured out how to solve this. I just don't understand why do I need to add the "#" symbol. (I don't see the question/instructions ask me to ADD "#" symbol)

EDIT

after seeing your answer, i guess there's a bug in their questions..

Thanks and have a GREAT weekend!

Challenge Task 2 of 2

Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".

I imagine it is just to get you accustomed to working/concatenating with various types of string and variable.