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

Task 1 no longer passing

Help?

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>

2 Answers

Brad McKinney
Brad McKinney
14,677 Points

Idk if this is the "right" way to complete this challenge, but this one took me a while to get past without help. How i passed Task 2 was i put the # symbol in the first line of code. Like so: var id = "23188xtr#";

Then i added a new line of code at the bottom to concatenate, as instructed. Like so: userName += lastName.toUpperCase();

Again, this might not have been the "right" or best way to solve the problem, but it worked.

Josef Aidt
Josef Aidt
7,722 Points

In my opinion that is the correct way, however I found it to be more concise to add onto the existing userName assignment.

var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Brad McKinney
Brad McKinney
14,677 Points

Josef Aidt , If the "userName" variable was assigned an uppercase version of the "id" variable, Would it also make sense to add another line of code like userName += "#" + lastName.toUpperCase(); ? even though it isn't as concise as your solution, would it still work?

This is what confused me, because that was my original solution, but it failed and i couldn't figure out why.

Hi Josef,

I had already tried this way you have given example of, however still get the same outcome that Task 1 isn't passing?

Josef Aidt
Josef Aidt
7,722 Points

Brad McKinney it should; either approaches are valid. Check Chrome's dev tools' JS console when submitting, if there is a syntax error in your code it will output to the console.

Anthony Harrison on the last line in your code you are missing the () at the end of the toUpperCase() method. I didn't notice that at first, however my statement about using another operator (+=) still stands.

Josef Aidt
Josef Aidt
7,722 Points

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

In your code, you are reassigning the value of userName to #SMITH instead of adding onto the username , which should be 23188XTR#SMITH. You will need to use an operator other than "=" to complete the final portion of the challenge.