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 trialTucker Humiston
1,025 Pointsjavascript strings problem
Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".
Is it just something small I am forgetting to put in?
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase(userName);
var userName = id + "#" + lastName;
document.write(userName);
<!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>
Tucker Humiston
1,025 PointsI changed the code to this but it doesn't work.
var id = "23188xtr"; var lastName = "Smith"; userName = userName.toUpperCase(); var userName = id + "#" + lastName;
Bogdan Martinescu
6,030 PointsThe code should be, as described above:
var id = "23188xtr";
var lastName = "Smith";
var userName = id + "#" + lastName;
userName = userName.toUpperCase();
document.write(userName);
Brett Comardelle
8,541 Pointsthe toUpperCase needs to be after you declared the variable, so just switch lines 3 and 4
2 Answers
Jacob Mishkin
23,118 Pointsyour really close on this all you need to do is concatenate the variables and the string into one variable. like this:
var id = "23188xtr";
var lastName = "Smith";
var username = id.toUpperCase() + "#" + lastName.toUpperCase();
and there you go. Happy coding.
Tucker Humiston
1,025 Pointsthank you.
Jacob Mishkin
23,118 PointsNot a problem! any time.
Bogdan Martinescu
6,030 PointsBogdan Martinescu
6,030 PointsYou need to remove line 3 and place before document.write :
userName = userName.toUpperCase();