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

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

How to concatenate the variables here?

Hi there, I'm not sure how to go about this challenge. I accomplished the first task easy enough, but the second is giving me trouble. I basically have to do just what the instructions say, but I'm not quite getting it. Could someone please help with this? Thanks!

app.js
var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase();
assignment += "#";
var assignment = lastName + id.toUpperCase();
index.html
<!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>
Max Kutner
Max Kutner
7,595 Points

Hi,

Here is the code:

var userName = id.toUpperCase(); userName = userName + '#' + lastName.toUpperCase();

Hope it helps! Lemme know if it doesn't make sense!

Max

3 Answers

Steven Parker
Steven Parker
231,007 Points

You had the right idea, string concatenation is done with the plus sign (+). I think you just got confused about the fact that you were still working on the assignment for userName. You want something like this:

var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Collin Perkins
Collin Perkins
8,811 Points

All you need to do is add on to what you had in the first code assignment on the userName var through string concatenation.

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();

Ok, I get it now. Thanks so much!

geoffrey
geoffrey
28,736 Points

Don't forget to mark the answer that helped you the most as best answer :)