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

Martin Bornman
Martin Bornman
Courses Plus Student 12,662 Points


What is wrong with this code in the toUpperCase method of JavaScript?

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

var userName = '# ' + lastName.toUpperCase();
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="app.js"></script>

2 Answers

Tobias Helmrich
Tobias Helmrich
31,602 Points

Hey Martin,

I guess you're talking about the second task of the challenge. If so, your code has a few problems. Firstly you removed the uppercase version of id but you need the id as well for the second task. Then you should concatenate the variable id in uppercase with a # symbol and the lastName variable in uppercase as well. Like so:

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

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

Also note that you shouldn't write a space after the # symbol.

I hope that helps, if you have further questions feel free to ask! :)

Keli'i Martin
Keli'i Martin
8,227 Points

It looks like in task 1, you were to assign an all uppercase version of id to the userName variable. Then, in task 2, you need to use string concatenation to append a "#" and the all uppercase version of lastName to the end of what you did in task 1. In other words, your variable assignment should look like this:

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

Hope this helps!