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 trialAndrew Nicholson
2,474 PointsWhat have I done wrong here?
I am super confused as to why this won't work - do I need to add a second statement to the lastName var? I can't understand how else I can add the '#' by concatenating if it's not done the way I've done it here...
var id = "23188xtr";
var lastName = "Smith";
var 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>
1 Answer
Marcus Parsons
15,719 PointsHey Andrew,
Although your code is perfectly valid and usable, the challenge wants you to use the toUpperCase()
method on both the id
and lastName
variables and set userName
equal to that new value. The reason being is that just calling userName.toUpperCase()
by itself doesn't change the value of userName
. You have to assign that new value back to userName
.
So, you have a couple options here:
1) Modify your code so that userName
actually gets the new upper case value:
var id = "23188xtr";
var lastName = "Smith";
var userName = id + "#" + lastName;
userName = userName.toUpperCase();
2) Or use the toUpperCase()
method during concatenation.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Either one of these methods is valid and either one will pass the challenge.
Andrew Nicholson
2,474 PointsAndrew Nicholson
2,474 PointsAh I see, thanks for the help Marcus.
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsYou are very welcome, Andrew. Happy Coding!