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

Elizabeth Barker
seal-mask
.a{fill-rule:evenodd;}techdegree
Elizabeth Barker
Front End Web Development Techdegree Student 1,153 Points

I am not sure how to complete task 2 in this series.

I tried:

var userName = id.toUpperCase();

for the first task then

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

for the second task, but the message when I checked work was that the first task was no longer passing.

Ken Alger
Ken Alger
Treehouse Teacher

Edited for markdown.

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Elizabeth;

Welcome to Treehouse!

The error you received typically means that the new code you added has syntax errors that prevent to code from running properly at all. Your Task 1 code looks great. Let's take a look at Task 2.

Task 2

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


You have the correct idea, but, as I mentioned, the syntax was off a bit. We want to take the old variable of userName and concatenate all that other stuff to it, right? Here is one example of doing that:

task2.javascript
userName  = userName + "#" + lastName.toUpperCase();

We could achieve the same thing by combing both tasks into one line like:

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

That works as well, but I think for the purposes of explanation separating the tasks out into two lines of code better represents what is going on.

Post back if you are still stuck or have further questions.

Happy coding,
Ken