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

James O'Brien
James O'Brien
1,103 Points

On my last nerve trying to get '#' between id and lastName. I've tried everything.

This seems so basic but I've tried every possible way to put '#' between id and lastName.

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

This seems like it would work but I still get the Bummer message. I've tried every different way and nothing works. I've even tried putting '#' into it's own variable and it doesn't work.

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

var userName = id + '#' + 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>

2 Answers

Hi James,

While I haven't completed the current challenge you are working on, I suspect it may be because the id.toUpperCase(); isn't 'saving'. This is because when you call .toUpperCase(); it will return a new string but you are not saving the returned value to a variable.

On the other hand, the output of lastName.toUpperCase(); is being saved as part of the concatenated string to the variable named userName.

I'm assuming that the expected output is "23188XTR#SMITH".

I'll add some comments and tweak the code you provided, to illustrate this:

var id = "23188xtr";

id.toUpperCase(); //=> Returns "23188XTR"
console.log(id); //=> prints "23188xtr"

var lastName = "Smith";

var userName = id + '#' + lastName.toUpperCase();
console.log(userName); //=> prints "23188xtr#SMITH" rather than "23188XTR#SMITH"

Cheers,

Jacob

James O'Brien
James O'Brien
1,103 Points

That was it! Thankyou! :)

Awesome! I'm glad to help!

I'm currently working through Tree House's career program, part of the process is to earn points on the forum through answer up-votes and 'best answers'.

It would be insanely helpful if you would be so kind to either up-vote and/or mark my answer as 'best answer'!

Cheers, Jacob