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 trialShilpa K
12,722 PointsComplete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastNa
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".
I am not sure what I'm doing wrong here, could someone help me with this code challenge?
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
userName + "#" + lastName.toUpperCase();
20 Answers
Gloria Dwomoh
13,116 PointsIt says... "Complete the assignment to the userName variable" so you have to add things to that variable instead of a new line.
var userName = id.toUpperCase()+ "#" + lastName.toUpperCase();
Shilpa K
12,722 PointsAh, thank you!
Gloria Dwomoh
13,116 PointsYou are welcome. As the instructor said below if you want to assign it to username. The other way round is to do it this way
userName += "#" + lastName.toUpperCase();
this is a 2nd correct solution to it.
Markus Mönch
16,383 Pointswrong! doesnt work
Gloria Dwomoh
13,116 PointsMarkus Moench - I do not think it is wrong, at least not for the time it was written at. Since this is an old question though there could be changes in the curriculum or maybe something wrong with your code.
Rodney Buljubasic
Courses Plus Student 13,899 PointsI also dont know where the # came from.
var id = "23188xtr"; var lastName = "Smith";
var userName = (id.toUpperCase() + "#" + lastName.toUpperCase());
NOTE: only from task 2 of 2
Nancy Mare
6,572 Pointswhat does the # stand for?
Joe Williams
4,014 PointsI was also able to do this and got a correct answer:
var userName = (id + "#" + lastName).toUpperCase();
Natasha Johnson
12,285 PointsJoe, You are correct. THANKS!
Dave McFarland
Treehouse TeacherHI Shilpa K
You need to assign an uppercase version of the id
variable, plus a #
symbol plus an uppercase version of the lastName
variable to the userName
variable.
This line of code
userName + "#" + lastName.toUpperCase();
doesn't assign a value to userName
-- you need an equals sign to assign a value to a variable.
Cora Weiss
Courses Plus Student 1,271 Pointsmy correct answer did not incluse the # symbol
var userName = id.toUpperCase()+lastName.toUpperCase();
Kleovrotos Tsimperis
Courses Plus Student 13,831 PointsDave, why does the code userName += id.toUpperCase() + "#" + lastName.toUpperCase(); needs the "#" element to be correct? It doesn't mention at any point that the hashtag should be part of the string userName??
Dave McFarland
Treehouse TeacherThe instructions for the second part of the challenge state: "Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH"."
jiwan gurung
4,248 Pointswhy do u need to ad a hashtag?
jamesoneill
5,167 PointsTask one:
var id = "23188xtr"; var lastName = "Smith";
var userName = id.toUpperCase();
Task two:
var id = "23188xtr"; var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Paul Taylor
9,914 PointsThat was grossly confusing....So to clarify is '' the same as ""? Because that's why it wouldn't allow me to pass.
Ethan Young
3,388 PointsAfter several failed attemps and several instances of me screaming at my computer, I decided I had enough of the code challenge being full on retarded, so I did the code until the point where it said it was "23188xtr#smith" and not "23188XTR#SMITH" so I manually went into the code and changed the ID variable from 23188xtr to 23188XTR and I changed the lastName variable from "smith" to "SMITH", and then it finally decided that it wanted to work.
I know I probably cheated the system but I was tired of it being stubborn with me when I know I was using the right code.
Markus Mönch
16,383 PointsIt is a very bad platform if u do the right thing but it says it is wrong.
Cesar De La Vega
13,900 PointsThis worked for me
userName += "#" + lastName.toUpperCase();
Michael Norris
2,105 PointsAfter SEVERAL attempts on this exercise, this worked! In the TTH program, I think it is getting "hung up" on the variable userName and in turn making this exercise extra challenging. It should not be this difficult!
Luke Vaughan
15,258 Pointsvar userName = "23188XTR#" + lastName.toUpperCase()
this worked for me
Markus Mönch
16,383 Pointsthat works but it should not work like that.,
Markus Mönch
16,383 Pointswhy is no instructor here clarifying clearly what the problem is here? I write what the moderator posted
var userName = id.toUpperCase()+ "#" + lastName.toUpperCase();
and it doesnt work
it says you only need to call 'toUpperCase()' on 'id' and 'lastName'
Markus Mönch
16,383 Pointsvar userName = id.toUpperCase(); username += "#" + lastName.toUpperCase();
also doesnt work
Dave McFarland
Treehouse TeacherMarkus Moench what error are you seeing when you type this?
Andres Ramirez
18,094 Pointsvar id = "23188xtr"; var lastName = "Smith";
var userName = id.toUpperCase();
Tobia Crivellari
14,331 PointsHi!
I've tried this line of code for this challenge:
userName += id.toUpperCase() + "#" + lastName.toUpperCase();
Could you explain me why is not working? I can't figured out...
Thank you!
Tobia.
Jordan King
1,286 PointsHi Tobia, I had a annoying time with this question, but managed to figure it out. I simply wasn't remove the ; after the first part id.toUpperCase(); The reason why yours isn't working is because you have done += from what I know its adding userName = userName
it should be
userName = id.toUpperCase () + '#' + lastName.toUpperCase ();
Juan Aviles
12,795 PointsI'm having problems with this as well. I understand the solutions above, but I'm curious to know why you can't use concatenation to create the string, then toUpperCase on the entire string like this:
var id = "23188xtr";
var lastName = "Smith";
var userName = id + "#" + lastName;
userName.toUpperCase();
I get this result when I try to enter it:
Bummer! Did you add the '#' character between id
and lastName
?
Charles Cunningham
7,322 PointsUp until this point of this track, I've had very few times where I've been stuck but this one got me hard. I went through the community forums after countless trial and error only to find other with the same issue. When I finally passed the challenge, I almost felt obligated to come back and put my small bit of help into it.
After going through and trying all other lines of code pasted here and reading other peoples' methods, I kept failing. Task 1) If you set the id.toUpperCase in the console.log() it is accepted. Task 2) Make sure, I mean absolutely sure that your words are capitalized in the correct areas. lastname won't work, make sure the 'N' in lastName is capped. protip: Just set the line of code inside the var userName to keep it a little more simple and stop yourself from getting overwhelmed with the code. (It helped me get it finished correctly and actually retaining a little more than I thought I would.)
Also, this was my solution. Like I said, posting it inside the var userName keeps it simple and still correct. var userName = (id.toUpperCase()) + '#' + (lastName.toUpperCase());
cesardiaz3
5,443 Pointsif you follow along the instructor did mention how Concatenation works with strings
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".
the code stated
`
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
\
`
the += is shorthand for combining a value inside a variable with another value.
(JavaScript)userName += "#" + lastName.toUpperCase();
\\
Ivana Lescesen
19,442 Pointsvar userName = id.toUpperCase(); userName += "#" + (lastName.toUpperCase());
Coding Lab 9
836 PointsAfter completed the Task 1, I tried userName += "#" + (lastName.toUpperCase()); and userName + "#" + lastName.toUpperCase(); for the second task, but the system keep saying it looks like the Task 1 is no longer passing. Couldn't figure it out what part is wrong.
Jefferson Snow
1,357 PointsI answered with :
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
And the site came back saying : Bummer! The userName
variable is "23188XTR#SMITH" not "23188XTR#SMITH".
The answers are identical. Am I crazy or is something wrong?
Phong Somlith
5,675 PointsJefferson, I'm having the exact same issue as well. I thought I was going nuts but after verifying, those answers are completely identical as what you stated. I'm still trying to figure this one out...
Jazzy schaeffner
2,091 PointsI used this and it was correct!
var userName = id.toUpperCase();
Adriano Gomes
5,468 PointsMy answer was var userName = id.toUpperCase(); and it was correct as well.
John Mutch
6,962 PointsJohn Mutch
6,962 PointsThis is the code I wrote and it works but it is not what the instructions requited.
just saying!