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

Bram Huisman
Bram Huisman
7,387 Points

What am i doing wrong?

I don't know what i am doing wrong?

app.js
var id = "23188xtr";
var lastName = "Smith";
var upperCase = id.toUpperCase();
var userName = upperCase;

lastName.toUpperCase;
userName += '#' + 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>
Bram Huisman
Bram Huisman
7,387 Points

This is the challenge:

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".

2 Answers

Alex Heil
Alex Heil
53,547 Points

hi Bram Huisman , I guess the checker might be a little bit confused because you added a new variable instead of adding to the userName variable in the first place. also on your 2nd last line where you call .toUpperCase on the lastName this has no effect on the final line as you're not changing the value of the variable itself.

let me walk with you through the whole challenge and I hope this will help you:

T1: Assign an all uppercase version of the id variable to the userName variable.

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

var userName = id.toUpperCase();

explanation: in the already exisiting variable userName I referenced the id variable and called toUppercase on it to make the whole text uppercase.

T2: 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".

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

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

explanation: to the last step I added the # and then (same way as in T1) I referenced the lastName variable and called toUppercase on this as well. so we get exactly the result we want, everything is uppercased and the hash symbol in the middle.

I hope this helps you out, have a nice day ;)

Bram Huisman
Bram Huisman
7,387 Points

Thank you! :D looks obvious now xD