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 trialMartin Bornman
Courses Plus Student 12,662 PointstoUpperCase
What is wrong with this code in the toUpperCase method of JavaScript?
var id = "23188xtr";
var lastName = "Smith";
var userName = '# ' + lastName.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
Tobias Helmrich
31,603 PointsHey Martin,
I guess you're talking about the second task of the challenge. If so, your code has a few problems. Firstly you removed the uppercase version of id but you need the id as well for the second task. Then you should concatenate the variable id in uppercase with a # symbol and the lastName variable in uppercase as well. Like so:
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Also note that you shouldn't write a space after the # symbol.
I hope that helps, if you have further questions feel free to ask! :)
Keli'i Martin
8,227 PointsIt looks like in task 1, you were to assign an all uppercase version of id
to the userName
variable. Then, in task 2, you need to use string concatenation to append a "#" and the all uppercase version of lastName
to the end of what you did in task 1. In other words, your variable assignment should look like this:
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Hope this helps!
Martin Bornman
Courses Plus Student 12,662 PointsThanks Keli'i
Martin Bornman
Courses Plus Student 12,662 PointsMartin Bornman
Courses Plus Student 12,662 PointsThank you Tobias!!!