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

Please explain

Can some please tell me in simple terms what the # is for?

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

3 Answers

var id = "addsxa";
var lastName = "Fero";

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

so userName will have STRING with will be : "ADDSXA#FERO", you just combine 2 string values also "#" into one and "#"is here because you want somehow know where ID ends and where lastName starts :) because with "ADDSXAFERO" you are unable to tell me where last name starts :)

Thanks for that. I just don't recall being told about the # in earlier examples. I understand the concept now. Your explanation I take that as granted BUT Would I be wrong to say that the # represents a space between the first and last name, therefore the system formulates (two separate words) a first and last name?

you can give anything in "#" but "#" is more cooler you know battle.net ? all users have USERNAME#13213 , and why not USERNAME 13213 ? think little bit its easyest to read and its cooler with "#" :smile: and its easyer seachr for 1 string then make from it 2 string and then search 1 string in our database then 2nd string ( this is just example )

Lol, that's a bit way over my head. Understood the first sentence but not sure of your meaning when you say search for 1 string in our database then 2nd string. However, the reply is much appreciated and sure I will fully understand at some point.

In this case, the "#" is just another string that is being concatenated (added) to the other two strings.

The "#" has no syntactic meaning in this context. Instead of placing a "#" inside of the string, you could do the same with a space.

var id = "addsxa";
var lastName = "Fero";

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
return userName; //would return "ADDSXA#FERO"

var userName = id.toUpperCase() + " " + lastName.toUpperCase();
return userName; //would return "ADDSXA FERO"

Computers do exactly what you tell them to do! Concatenation of strings will not add any extra characters like spaces for you. If you were to concatenate the two variables without adding a string between them, the resulting string would be the two smushed together.

var id = "addsxa";
var lastName = "Fero";

var userName = id.toUpperCase() + lastName.toUpperCase();
return userName; //would return "ADDSXAFERO"