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

Code confirmed as correct but multiple sources, including the workspace, but still generating a Bummer notification!!??

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

End result - Bummer! The userName variable is "23188XTR#SMITH" not "23188XTR#SMITH".

I've had a couple of JS pro's look at this, they cant see what the problem is, we've concluded that its a bug - have we got this wrong or is it what we think it is?

Thanks guys

Hey please link the challange. Just because the "code is correct" it does not mean that you followed the challange instructions word by word.

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! First, your code is functional. However, it's doing something the challenge is not expecting and hasn't asked for. You are overwriting the original value of lastName with the upper case version of that. It wants you do this without altering the original value. Take a look:

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

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

Essentially, the problem with your code is this line:

var lastName = lastName.toUpperCase();

This line completely overwrites the original value stored in the variable. And while the output you will display will be correct, the value stored in the variable will not. Hope this helps! :sparkles:

Thanks Jennifer! Most appreciated, I'll have another play around - hopefully I'll succeed this time :)

Thanks once again

Jennifer Nordell - Thank you so much for that pointer - I completely removed the line and we appeared to get there :) somewhat confused as to how but have noted down as an area for additional research!

Thanks once again

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I'd suggest re-reading my explanation. Imagine that I'd added this extra line of instructions to the current instructions: "Do this challenge without changing any of the original values of the variables". The problem was that you were resetting the value stored in lastName from "Smith" to "SMITH". The challenge wants you to print out the result of capitalizing the variable without actually changing the value stored in it.