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

kayla hopwood
seal-mask
.a{fill-rule:evenodd;}techdegree
kayla hopwood
Front End Web Development Techdegree Student 570 Points

I'm typing it exactly how it told me to and is still telling me i'm wrong. Do I need to delet the id.toUpperCase();

It would be great if these quizzes can give clearer explanations why i am wrong. I have typed it the exact way it told me and is still telling me I am wrong.

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

var userName = id.toUpperCase();
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>
itsuncleslam
itsuncleslam
12,662 Points

You are almost correct but take a look at your quotations. The lastName.toUpperCase() returns a string and should not be within the quotes. Also, you cannot perform string concatenation from within a string.

1 Answer

Cheo R
Cheo R
37,150 Points

What you want to end up with is something like

"23188XTR#SMITH".

Your code

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

Is close. You are assigning to userName twice.

In the first instance, you are assigning to userName as stated in the prompt.

In the second, you're overriding what you had before and assigning the string "# + lastName.toUpperCase()" to userName.

The problem with the above, is that you're not getting (as a string) the result of calling lastName.toUpperCase(). You're actually assigning the characters lastName.toUpperCase() to userName. You can get the result of calling lastName.toUpperCase() by either using interpolation with backticks ` `, i.e. lastName.toUpperCase() or you can concatenate the result to the rest of the string.

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

// or 

userName = `${id.toUpperCase()}#${lastName.toUpperCase()}`;