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

Sarah Breidenbach
Sarah Breidenbach
4,490 Points

Why is the 3rd line in the String Methods Challenge necessary? Wouldn't the 4th line of the solution work without it?

It makes more sense to me to omit the third line and just use these three lines:

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

Is there a reason that this line of code - id + "#" + lastName; should be used before the userName variable is declared?

1 Answer

Steven Parker
Steven Parker
231,275 Points

The challenge provides you with two complete statements and the beginning of a third line for you to finish:

var id = "23188xtr";
var lastName = "Smith";

var userName

There's no "fourth line" so if you have more than 3 lines you must have added something.

Sarah Breidenbach
Sarah Breidenbach
4,490 Points

Oh. Well, there are 4 "lines" but the 3rd one was blank. For some reason I thought I was supposed to put code there. But it accepted my answers as correct with code on all four lines. Not sure what I put there anymore. Weird.