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 trialDavid Michael Bryant
5,068 PointsConcatenation conundrum.
If someone could clarify what I'm missing I'd be grateful! Thanks!
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
var userName += "#" + lastName.toUpperCase();
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
3 Answers
Christopher De Lette
Courses Plus Student 7,139 PointsHi David,
To concat variables for this challenge you can try the following method:
var id = '23188xtr';
var lastName = 'Smith';
var username = id.toUpperCase() + '#' + lastName.toUpperCase();
hope this helps
Take care and happy coding!
Steven Parker
231,269 PointsYou were really close! What you have there is fine except for just one thing: you can only declare a variable one time.
So just remove the "var" from the last line and you'll have it.
David Michael Bryant
5,068 PointsI tried that as well, and it was apparently looking for it to be all on one line. In your suggestion, it told me that question 1 was now incorrect. I'm guessing because it replaced the variable altogether right? JS lets us get away with not putting var and it still creates the new variable doesn't it?
Steven Parker
231,269 PointsYou already declared the variable on the previous line, so this would not be a case of implicit declaration. By removing the "var" from the second line it becomes an ordinary assignment, which can be done any number of times in the life of a variable.
David Michael Bryant
5,068 PointsGuess it just really wanted that one liner. Badum bum. Chhh
Thanks!
Steven Parker
231,269 PointsIt works either way. After removing that last "var" your original code passes also.
David Michael Bryant
5,068 PointsDavid Michael Bryant
5,068 PointsI managed to get it and that was indeed the solution. Thank you for the quick response!