Welcome to the Treehouse Community
Looking to learn something new?
Kennen Pflughoeft2,749 Points
Getting at message that Task 1 is not passing, but if I concatenate this sting, shouldn't Task 1 not pass here?
I'm not sure how both task 1 and task 2 should pass once I concatenate this string, this makes it hard to trust this error message.
var id = "23188xtr"; var lastName = "Smith"; var userName = id.toUpperCase(); var userName += "#"; var userName += lastName.toUpperCase();
Jason AndersTreehouse Moderator 145,624 Points
Hi Kennen, The reason you are getting the error, is because your are using 'var' on each instance of the concatenation. The challenge complier just sees this error and returns that the first task is no longer passing, because the value for user name is now "lastName.toUpperCase(). Every time you use var, you are basically wiping whatever was in there before and putting in a new value.
The correct way to concatenate this string (and being DRY) is
userName = userName + "#" + lastName.toUpperCase(); //do not use var in the front.
Hope that makes sense. Jason :)