Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

Rhiannon Sadler
Rhiannon Sadler
351 Points

I am stuck on section two of my challenge

the code i have on the screen already is.
var id = "23188xtr"; var lastName = "Smith"; var userName = id.toUpperCase(); And the instruction i was given is Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTRSMITH"

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>

2 Answers

I'm late to the party; my version of the solution looked like this:

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

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

Glad you got it sorted!

Steve.

Rhiannon Sadler
Rhiannon Sadler
351 Points

Thankyou bud! still nice to look at alternatives to it was still a big help.

No problem! :+1:

JS isn't 'my thing' but feel free to tag me in any posts you make in here and I will try to help. You can do that Twitter-style with the 'at' symbol - Rhiannon Sadler <- like that. :smile:

:+1:

Justin Radcliffe
Justin Radcliffe
18,987 Points

Hi Rhiannon,

This will work:

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

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

In the last 2 lines of code we're concatinating the # symbol, then the lastName variable converted to upper case.

[MOD: edited code block - srh]

Rhiannon Sadler
Rhiannon Sadler
351 Points

sheesh, thankyou. I this course is really stepping up its skills huh. i would have never worked that out no matter how many times i watched the video again. Thankyou!