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

Chad Duncan
Chad Duncan
1,246 Points

Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "231

I am so not understanding what the answer is here....

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

var userName = id.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>

16 Answers

You need to concatenate var userName and var lastName. Remember everything inside quotes becomes a string

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

var userName = id.toUpperCase() + "#"; // 23188XTR#

userName += lastName.toUpperCase(); // 23188XTR#SMITH

Hello !

Me too completely lost, I finally passed the test:

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

var userName = id.toUpperCase() + lastName.toUpperCase();
Jonathan Wogenius
Jonathan Wogenius
1,981 Points

HI, This works:

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
var userName = id.toUpperCase() +'#' + lastName.toUpperCase();
Nadia Masiero
Nadia Masiero
3,468 Points

This is correct. Thanks!

Eniko Pap-David
Eniko Pap-David
4,798 Points

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

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

This is just frustrating ....

Concatenate the hash symbol and the lastName variable to what you have from the first part of the challenge.

The lastName string also needs to be upper case as well so you will have to call that method again.

Chad Duncan
Chad Duncan
1,246 Points

Its starting to make sense, Im just for some reason not setting it up right.....

MD NOMAN HOSSAIN
MD NOMAN HOSSAIN
10,833 Points

It should be like this...

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

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

billy mccoll
billy mccoll
2,307 Points

task 1 asks you to give this answer so the second part asks you to add how i solved this was easy just remove semi colon

var userName = id.toUpperCase();

task 2 answer removing the semi colon then fill in what the question asks add # now by using + add your last part lastName.toUpperCase() and now add the semi colon....

hope this helps

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

Off Course the semicolon Closes it ..Thanks

Jon N
Jon N
829 Points

You need to add .toUpperCase before lastName This makes me want to give up coding. It's so complicated! I never would have gotten it right. If you lost concentration for 2 seconds, it all becomes gibberish.

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

var userName = id.toUpperCase()+ '#'+ lastName.toUpperCase();
Chad Duncan
Chad Duncan
1,246 Points

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

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

this is my answer, it is now telling me "Oops! It looks like Task 1 is no longer passing."

Any incite on what i am doing wrong here?

Sorry I'm late!

You almost have it. I actually tried the same thing when I went over it.

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

//Needs to be 23188XTR#SMITH

var username = id.toUpperCase() // '23188XTR'

var username = id.toUpperCase() + '#' // '23188XTR#'

var username = id.toUpperCase() + '#' + lastName // 23188XTR#Smith

//Finish up by adding the toUpperCase method to what needs to be uppercase. 
Andrew Aramouni
Andrew Aramouni
2,370 Points

i did userName = id.toUpperCase(); userName += '#'; userName += lastName; /* So it said it was working. I seriously dont see a problem with it. *\

Chad Duncan
Chad Duncan
1,246 Points

I completely forgot to post... after doing some searches on line i finally figured out the answer... although, it looks different from here, it still passed... thanks so much for the help!!

Midhun Chandran
Midhun Chandran
9,414 Points

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

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

Andrew Aramouni
Andrew Aramouni
2,370 Points

sorry IT WASNT WORKING. Thats what i meant to say.

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

Chad Duncan
Chad Duncan
1,246 Points

this is driving me crazy... lol

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