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

Sam Weeks
seal-mask
.a{fill-rule:evenodd;}techdegree
Sam Weeks
Front End Web Development Techdegree Student 16,699 Points

not sure where i'm going wrong...

Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName variable.

Bummer: The userName variable is "23188XTR#lastName" not "23188XTR#SMITH".
app.js index.html

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

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

var userName = (id.toUpperCase());

userName += "#lastName";
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>

1 Answer

John Lack-Wilson
John Lack-Wilson
8,181 Points

So the problem here is that the last line of your code is concatenating the id in upper case with #lastName (the literal string).

The challenge wants you to concatenate the id (upper case) with a '#' and the value of the lastName (upper case) variable.

Consider the code below:

var fName = "Sam";
var lName = "Weeks";

var fullName = fName.toUpperCase() + " " + lName.toUpperCase();

The above variable fullName would be assigned "Sam Weeks".

Sam Weeks
seal-mask
.a{fill-rule:evenodd;}techdegree
Sam Weeks
Front End Web Development Techdegree Student 16,699 Points

still confused thanks for helping though

Bummer: The userName variable is "23188XTR" not "23188XTR#SMITH". app.js index.html

var id = "23188xtr"; var lastName = "Smith"; ā€‹ var userName = (id.toUpperCase()); ā€‹ var fullName = id.toUpperCase() + "#smith" + lastName.toUpperCase();

John Lack-Wilson
John Lack-Wilson
8,181 Points

Ok so my example is using variables that you shouldn't be using in this challenge - it was to try and emphasise the point. You should continue to use userName, as that it what the challenge expects to see.

userName should contain this exact value: 23188XTR#SMITH

As the lastName variable contains "Smith", we can use this variable along with the .toUpperCase() method.

Here's an example:

var id = "2111otf";
var lastName = "Weeks";

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

The above code would result in the userName variable having the value: 2111OTF#WEEKS

Sam Weeks
seal-mask
.a{fill-rule:evenodd;}techdegree
Sam Weeks
Front End Web Development Techdegree Student 16,699 Points

Yea i can see now you were trying to help by giving me a different example i just took your first bit of code as literal and got confused cheers mate understand it a bit clearer now