Welcome to the Treehouse Community
Looking to learn something new?
Elena Paraschiv9,938 Points
Using String Methods challange_code
Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH". Did someone manage to fix this?
var id = "23188xtr"; var lastName = "Smith"; var userName = id.toUpperCase(); userName = lastName.toUpperCase(); username = "id" + "#" + "lastName";
There are a number of ways to solve this challenge, but the most important concept to take away is that when doing operations with variables, such as concatenation with strings, you do not put those variable names inside of quotes. You just put the variable name itself.
Also, you have to think about what the end result is. The string should be upper case id, a # sign, and then upper case last name. With the way you have it right now, it starts out as upper case id. Then, it is overwritten and becomes only upper cast last name. Then, it is overwritten a 2nd time and becomes a string that says "id#lastName". It needs to have the values contained within
lastName. In order to do that, you just use the variable name as I mentioned above.
The simplest method to solve this is to just add the "#" after putting id to upper case and then add last name to upper case.
var id = "23188xtr"; var lastName = "Smith"; //put the upper case version of id plus a # plus last name to upper case var userName = id.toUpperCase() + "#" + lastName.toUpperCase();