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 trialLatina Bell
496 PointsNot sure how to combined the variables
I am not sure how to add uppercase and combined these two variables. I have tried a few different methods but nothing seems to be working
var id =("23188xtr");
var lastName = id.toUpperCase ("#+ Smith");
id.toUpperCase ("id + lastname")
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>
1 Answer
Steven Parker
231,236 PointsTo join strings by concatenation, the "+" symbol must appear between the strings instead of inside them.
Robert Schaap
19,836 PointsRobert Schaap
19,836 PointsLeave the original variables, they're fine. String methods can be chained easily. So
"john" + "smith"
will output as"johnsmith"
. Same thing goes for the.toUpperCase()
method which you can put at the end of a string.Your last line in app.js will convert id to uppercase just fine. Now you just need to add a hash, and then add the lastName variable converted to uppercase. It looks a bit strange but you can do it all on one line.
"string" + stringVariable.method() + "string"
is perfectly fine.