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

I am trying to create a program which makes the end result uppercase and it is not working

Here is the code: var id = "23188xtr"; var lastName = "Smith"; lastName.toUpperCase(); id.toUpperCase(); var userName = id + "#" + lastName; userName.toUpperCase(); document.write(userName.toUpperCase()); I am not sure what I am doing wrong. I want the end result to be 23188XTR#SMITH

app.js
var id = "23188xtr";
var lastName = "Smith";
lastName.toUpperCase();
id.toUpperCase();
var userName = id + "#" + lastName;
userName.toUpperCase();
document.write(userName.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>

4 Answers

Sean Johnson
Sean Johnson
8,025 Points

I believe you can exclude the parts I marked down below, once you remove it, try again and see if it works

var id ="23188xtr";
var lastName = "Smith";
id.toUpperCase(); //Remove this, this is not needed
lastName.toUpperCase(); //Remove this, this is not needed

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

document.write(userName.toUpperCase()); // Remove this, this might be what is causing the problem
Sean Johnson
Sean Johnson
8,025 Points

Looking at the challenge for this, they want you to use string concatenation.

You should concatenate the string like this

userName = id.toUpperCase();

userName += '#';

userName += 'The last part goes here'

Thank you so much. This is what I changed it to and it is still giving me an error var id = "23188xtr"; var lastName = "Smith"; id.toUpperCase(); lastName.toUpperCase(); var userName = id.toUpperCase(); userName += '#'; userName += lastName.toUpperCase(); document.write(userName.toUpperCase());

thank you

Bo Christensen
Bo Christensen
5,924 Points

Hey Monica. I just tryed to look at your code. No reason to all you toUpperCase. besides the one your using in document.write

It should work the way your doing, but you can do it like Sean said and you will only use 1 variable.