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 trialShihab Al Khandaqji
689 Pointshow do you do that
Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH". how do you do that??????
var id = "23188xtr";
var lastName = "Smith";
var userName = id.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>
3 Answers
Jaroslaw Adamowicz
11,634 PointsHi,
you need to use + operator to concatenate strings or concat function, so: you already have
var id = "23188xtr";
if you do something like
var idUpperCased = id.toUpperCase()
you will get "23188XTR", as expected.
Later you're asked to add hash, so you use + operator, so I could do this using my previous variable:
var someVariable = idUpperCased + "#"
or alltogether:
var someVariable = id.toUpperCase() + "#"
add the end you also need to add uppercased name to finish task. Also variable it all should be hold in is userName, so:
var userName = id.toUpperCase() + '#' + lastName.toUpperCase()
Please refere to code below:
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase()
I hope it helps :)
Cheers!
Steven Parker
231,269 PointsYou can connect strings together using concatenation.
The concatenation operator is the plus sign ("+
"). So for example, if you wanted to add the contents of a variable to a literal string:
name = "Kal-El";
greeting = "Hello, my name is " + name; // <- string concatenation
You can also do a concatenation assignment ("+=
") to add on to an existing string. That might come in handy for that last task.
I'll bet you can get it now without an explicit spoiler.
Shihab Al Khandaqji
689 Pointsit says task 1 is no longer passing
Jaroslaw Adamowicz
11,634 PointsHi Shihab, with code I provided at the end of my previous post, both tasks are passing ok.
Maybe you should check it with different browser?
Let me know if you still have a problem!
Steven Parker
231,269 PointsI'd need to see what the script code looks like after you modified it. If you show it here I will take another look.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsThat's another way than what I was suggesting, but it also works.