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

Problem in the exercise: "Finally, add a # symbol and lastName in uppercase to the end of the userName string."

var id = "23188xtr"; var lastName = "Smith"; var username = id.toUpperCase(); var username = username + '#'; var username = username + lastName;

I've tryed it with and without making "Smith" upper case, but everytime i get the message: "Oops! It looks like Task 1 is no longer passing."

Can someone explain it to me? Thanks

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 Points

A few things:

  • they want the variable to be called userName with a capital N not username
  • you only use the var keyword when you're declaring the variable. Then when you want to refer to that same variable, you just use its name, you don't use var again. If you did you'd be declaring a new variable and you don't want to do that in this case.
  • you need to convert lastName to uppercase as well before you add it on
  • you might make this a bit more concise by using the += operator, and by combined some of this stuff into one line, but it's not a deal breaker.

Here is my solution:

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
userName += '#' + lastName.toUpperCase();
Petr Holusa
Petr Holusa
Courses Plus Student 4,041 Points

Oh thanks mate! I didn't understand this exercise.. :(