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

Error in the challenge JS Using String Method

in this challenge exists an error, the first task is:

Assign an all uppercase version of the id variable to the userName variable var id = "23188xtr"; var lastName = "Smith";

var userName

i have writen var userName = ( id + lastName).toUpperCase (); and it worked or var userName = ("id" + "lastName".toUpperCase()); and worked too.

the next task that was required was to Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastNamevariable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".

this is the correct code that i tested in the console and worked

(id + '#' + lastname).toUpperCase(); but in the challenge it didn’t work

i had to change the code to:

var id = "23188xtr"; var lastName = "Smith".toUpperCase();

var userName = (id + '#'+ lastName).toUpperCase(); and it worked

1 Answer

Konstantinos Pedarakis
Konstantinos Pedarakis
21,301 Points

hi i've tested the challenge again. your code is correct and should be working, and indeed works in the console. the point here is that it does not say that is wrong, its just say that task 1 no longer passing, which means that it does not want to change the code in the fisrt task which is this var userName = id.toUpperCase(); so, in the next task you can do simply something like this var userName = id.toUpperCase() + "#" + lastName.toUpperCase(); to keep the first task untouched.