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
André Jönsson
1,153 Points"Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName"
I can't get past this assignment. I try doing this:
var id ="23188xtr"; var lastName ="Smith"; var userName=id.toUpperCase()+lastName
But all I get this error message:
The userName variable is "23188XTRSmith" not "23188XTR#SMITH".
So, question is: 1: Why does my code turn it into all caps? 2: Why does my code add "#" between the vars?
André Jönsson
1,153 PointsAndré Jönsson less than a minute ago
Thanks Cheo! However, I'm a bit confused. The task explicitly states for me to add an upper case version of the variable "id" to the variable userName - doesn't that imply that the result should be 23188TRSmith?
And, secondly - what does the "#" do? I watched the "lesson", but it doesn't mention the use of #.
2 Answers
Ben Basty
23,772 Pointsi think there is a logic error here and AndrE is right, there is no need to add the hashtag in task1, but u need to add a hashtag to pass the task. because in task 2, the same task appears and ask to add a hashtag again which was already done in task1.
Cheo R
37,150 PointsThe task explicitly states for me to add an upper case version of the variable "id" to the variable userName - doesn't that imply that the result should be 23188TRSmith?
And, secondly - what does the "#" do? I watched the "lesson", but it doesn't mention the use of #.
You want to make uppercase id so
"23188xtr"
becomes
"23188XTR"
Then you want to add the hash symbol (as a string), so
"23188XTR" + "#"
And finally you want to add the uppercase version of lastName, so
"Smith"
becomes
"SMITH"
Putting it all together, you get
"23188XTR" + "#" + "SMITH"
or simply
"23188XTR#SMITH"
Cheo R
37,150 PointsCheo R
37,150 PointsHello Andre, you're on the right track. All you need to do is to turn everything into uppercase and add the hash (#) symbol between id and lastname. So something like:
id.toUpperCase + add hash sign + lastName.toUpperCase