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

Jason Howie
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jason Howie
Full Stack JavaScript Techdegree Graduate 20,769 Points

String Method Challange

I can't seem to figure out what is wrong with what I'm doing. It line 4 is no longer in effect, but when I put in into a workspace and look at the console with console.log() it come through correctly.

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

var userName = id.toUpperCase();
userName += '#';
console.log(userName + 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>

3 Answers

Vidya Nair
Vidya Nair
4,507 Points

Well I think what the aim of this challenge is. is just to get you to assign the value of the fully concatenated and Uppercase "23188XTR#SMITH" into the variable, userName without needing an output.

So that may explain why you may see it in the console log, cos the value of var ="23188XTR#" has concatenated "SMITH" for you in the log, but that it doesn't pass on line 4 because it's full value is not stored into var userName.

So you could do this instead:

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

and then if you did this after:

console.log(userName);

I would think it would still pass. (but you don't really have to log anything).

Hope this helps!

Store it back into userName

You've added the hash to the end of userName and printed it out to the console with the lastName at the end but, you've not stored the lastName back to the end of userName. Instead of printing the result just add it the end of userName;