Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,660 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,660 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,660 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 :-)