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

Finn MacLean
Finn MacLean
2,945 Points

Concatenation error

Having trouble getting past this task, as it appears my Concatenation is not working? (not seeing my added # symbol)

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

Any advice appreciated folks, I have gone back through the videos but guessing i have not assigned it in the correct place.

cheers,

app.js
var id = "23188xtr";
id += '#';
var lastName = "Smith";
var userName = id.toUpperCase();
lastName.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>
Sean T. Unwin
Sean T. Unwin
28,690 Points

Edit: See below I noticed an issue afterwards with lastName

It works fine for me when I tested in Firefox's Scratchpad.

I tested:

var id = "23188xtr";
id += '#';
var userName = id.toUpperCase();
console.log(userName);
/**
 * Result
 */
// "23188XTR#"

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

Sorry, I didn't see that this was part of a code challenge.

You haven't assigned lastName to userName.

The following is my result which passed:

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

var userName = id.toUpperCase();

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

Good luck and happy coding. :)

Sean T. Unwin
Sean T. Unwin
28,690 Points

You need to assign lastName.toUpperCase() to a variable, like you did with id, as strings are immutable.

You can simply change the last line to the following and it will be fine:

lastName = lastName.toUpperCase();
Finn MacLean
Finn MacLean
2,945 Points

thanks for the swift answer. I did the same and checked with the Chrome console and it executed fine. Yet still get that error within the 'quiz section' just to check I have your suggestion correct:

var id = "23188xtr"; id += '#'; var userName = id.toUpperCase(); var lastName = "Smith"; lastName = lastName.toUpperCase();

thanks for your help though, much appreciated :-)