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 trialVanessa Yeo
1,080 PointsHow do I get a final value of "userName is 23188XTRA#SMITH" using string concatenation?
Can't seem to figure this question out.
Below is my code.
var id = "23188xtr"; var lastName = "Smith";
var userName = "23188xtr"; console.log(userName.toUpperCase()); var userName = "id" + # + "lastName"; console.log(userName.toUppercase());
Would appreciate the help. Thanks!
2 Answers
Abe Layee
8,378 PointsAll you have to do is assign the toUpperCase() method on each variable in the userName. Something like this.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Jason Desiderio
21,811 PointsVanessa Yeo - it looks like you are printing out the literal strings "id" and "lastName" instead of the strings the variables id and lastName contain. Take the quotes off the variables and put it around the # then it will print out as desired.
var userName = id + "#" + lastName;