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 trialKatriel Paige
9,260 PointsWhat is this challenge actually asking?
So this is using .toUpperCase on strings; but when I use id.toUpperCase(); it tells me that the answer is incorrect. Also that the answer they're looking for has a hash in it (when neither id or lastName variables have a hash character in them). So what's going on?
var id = "23188xtr";
var lastName = "Smith";
var userName;
userName = id + lastName;
username.toUpperCase();
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
2 Answers
Steven Parker
231,275 PointsYou'll need to include the "#" as an extra component.
So when you concatenate the strings, you'll have 3 parts instead of 2.
And be sure to perform the case conversions on the other 2 parts separately. In theory, you could convert the case after joining things together, but the challenge wants you to convert the components themselves.
Cory Harkins
16,500 PointsWhen you apply .toUpperCase() or .toLowerCase() or any "dot function." You are calling a method of an object. That will become clear the farther you progress, but for now, you should be aware that your variable "id" becomes an object, when you apply the method to it (.toUpperCase()).
You can't put a method on to a string literal, only the variable that contains that data. The method is saying "Hey buddy... everything stored here... in this variable.... yeah... go'n n make that upper case, SUPER SIZE ME!"
Steven is right about the # to complete the challenge and the completion of the components, I just hope to shed some light on why your method isn't working on a string. :)
Have a good day!
Katriel Paige
9,260 PointsThat and I had a typo in my code, which didn't help things either :)
Thanks!
Katriel Paige
9,260 PointsKatriel Paige
9,260 PointsOh, I see what happened (missing information / user expectation setup issue). I ended up doing the case conversions on the strings separately, but knowing the "#" was a separate part (thus, 3 parts total when concatenating) helped immensely. Should have realized, but :/