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 trialwillkey
3,650 PointsCompletely Confused
I don't understand how to answer this question of the JavaScript Basics code challenge. Please can someone help me to understand.
Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".
code below
var id = "23188xtr"; var lastName = "Smith";
var userName = id.toUpperCase();
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>
2 Answers
Robert Schaap
19,836 PointsYou can concatenate strings by using the + operator. So "will"+"key"
would come out as "willkey"
.
This even works when you're calling methods on string variables or just using the string variables directly. You should just be able to add a hash symbol by doing +"#"
and then adding the lastName
variable converted to uppercase.
It may feel a bit strange at first, but if the result of an operation is a string, you can use + to add it to another string.
Bob Allan
10,900 PointsThe answer is three separate short strings combined into one longer string.
id.toUpperCase() + "#" + lastName.toUpperCase();