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 trialDaniel Glennie
42,854 PointsWhy won't this concatenation work? I have tried += and x + y + z formatting.
I have created a variable called userName and assigned the output of toUpperCase(id). I have tried to add the # and SMITH like this
var userName = String.prototype.toUpperCase(id) + "#" + String.prototype.toUpperCase(lastName);
and like this var userName = String.prototype.toUpperCase(id); userName += "#"; userName += String.prototype.toUpperCase(lastName);
What am I missing?
var id = "23188xtr";
var lastName = "Smith";
var userName = String.prototype.toUpperCase(id);
userName += "#";
userName =+ String.prototype.toUpperCase(lastName);
<!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
Jennifer Nordell
Treehouse TeacherHi there! In your last line, you have the + and equals signs backwards. It should be +=
. But even if I change that, the challenge still fails. You ned to run the toUpperCase
method directly on the string in question.
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Hope this helps!
edited for accuracy and additional information
Here's the MDN documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
Daniel Glennie
42,854 PointsDaniel Glennie
42,854 PointsThank you! I noticed the += was the wrong way round right as soon as I posted the question but that didn't fix the problem. It seemed as if the final value assigned to userName was just "#" but I can't think why that would be.