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

Martin Bornman
PLUS
Martin Bornman
Courses Plus Student 12,662 Points

toUpperCase

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

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

var userName = '# ' + lastName.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

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!