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

Aaron Jones
Aaron Jones
637 Points

I don't know what to do?

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

This is the question that it asked me and i don't know what to do so some help would be great thank you!

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

var userName = id.toUpperCase("#" + lastName);
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>

4 Answers

ALFRED MOHENU
ALFRED MOHENU
1,499 Points

The statement is asking you to convert the id and lastName to uppercase and add # to it. This is known as concatenation. The error with your code is,

  1. You have not converted the lastName to uppercase.
  2. You are adding "#" and uppercase as arguments toUpperCase() and this is wrong.

To get the desired answer which is "23188XTR#SMITH", your code will have to look like something like this.

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Chris Loyd
Chris Loyd
1,272 Points

You have the concatenation of # and lastName as input to your toUpperCase method, which isn't going to work. It should look like this:

var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Aaron Jones
Aaron Jones
637 Points

For some reason the answers that you guys game me still isn't write it says that my answer for the first question is now invalid.

Chris Loyd
Chris Loyd
1,272 Points

Can you try resetting the exercise?

Aaron Jones
Aaron Jones
637 Points

I figured it out thank you though.