Welcome to the Treehouse Community
Looking to learn something new?
Shashaank Srinivasan2,440 Points
I've inserted the '#' symbol in quotations, what am I missing in the code?
Any help is greatly appreciated.
var id = "23188xtr"; var lastName = "Smith"; var userName = "id"+"#"+"lastName" .toUpperCase();
Navid Mirzaie Milani6,273 Points
@Shashaank Srinivasan what do you want to achieve? because when i just type the code you write in the example i get :
var userName = "id"+"#"+"lastName".toUpperCase();
result is: id#LASTNAME. So whats going wrong at your?
Rich Donnellan25,767 Points
You're literally outputting
"lastName". Variables will not work with quotes (single or double); remove them from
The problem as mentioned by Rich is the incorrect use of variables but also missing the task.
The task is asking to add a
# symbol and an uppercased version of the last name to the uppercase of the id.
// Your solution: var userName = "id"+"#"+"lastName" .toUpperCase();
Here you aren't using the variables
lastName but using the strings "id" and "lastName".
You want to use those as variables.
var userName = id + '#' + lastName.toUpperCase();
We have something closer to the solution, but now we're getting only the lastName variable to be in uppercase. To get the whole string to be uppercase we can either uppercase the individual parts or to uppercase the overall string as so:
// version 1 var userName = (id + '#' + lastName).toUpperCase(); // OR // version 2 var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Since we want to keep things DRY, we probably want to use the first version.
Charles C. Lee :D