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

Scott Jenkins
Scott Jenkins
310 Points

Can someone explain how this question works? Thanks!

Just not sure where to start? Will this all be on one line?

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

var userName =id.toUpperCase("23188xtr");
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>
Scott Jenkins
Scott Jenkins
310 Points

Here is the question. Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".

4 Answers

Ran ShemTov
Ran ShemTov
14,148 Points

maybe

 var username = id+"#"+lastName.toUpperCase():

you would first add the ID, than concatenate the "#". and than add the last name when it's uppercased.

deckey
deckey
14,630 Points

Hi Scott, to keep the task result from one to another, you need to separate userName in 2 lines.

First, do the uppercase method to get task 1 done. Then, add # and lastName as uppercase to the already capitalized userName

to avoid a complete spoiler, pseudo as:

userName = id as uppercased ;

userName + = hash + lastName as uppercase

hope it helps, good luck!

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

I got you Scott. Don't worry. I know it's tough at first. We all go through it.

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

The toUpperCase method needs to be called on each of the variables individually so that each piece gets uppercased. No need to pass anything in them, they don't need any arguments to work their magic. To add a # in between them you simply concatenate the hash in the middle with the "#" with + signs on each side so that it attaches to each of the variables.

Hope that helps. Keep up the coding.

Scott Jenkins
Scott Jenkins
310 Points

Thank you all for your help! I promise to get this stuff one day! lol