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

HELP,EM STUCK GUYS

Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH" var id = "23188xtr"; var lastName = "Smith"; var userName

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

2 Answers

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".

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

//+dont put 'id' in quotes
//var userName="id".toUpperCase();

//+In the previous step you should have used:
//var userName = id.toUpperCase();

//+dont define userName twice with var
//+use the variables, don't make new strings
//+you forgot to add the # symbol
//+you did not assign the correct value.  # sign missing, "xtr" still lowercase
//var userName="23188xtr"+"SMITH";

var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Abe Layee
Abe Layee
8,378 Points

I see few errors in your code

var id = "23188xtr";
var lastName = "Smith";
var userName="id".toUpperCase(); // don't add quote around the var.... this is now a string not a var anymore
var userName="23188xtr"+"SMITH";

You goal here to use the toUpperCase() on both id and lastName var. The toUpperCase() method turns all letter to a capitalize letter. Like this

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