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 trialClint Dehner
8,808 PointsTask 2
I'm having issues with bringing the variables together with the # sign Im not sure what I'm doing wrong here...
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase();
var userName = 'id'+'#' + 'lastName';
lastName.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>
4 Answers
Jason Cawood
6,296 PointsHello Clint and Damien:
Damien you are correct except, toUpperCase() method doesn't actually modify the variable.
I believe what you are looking to do is something like:
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase();
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Damien Watson
27,419 PointsHi Clint,
You have declared the variables in line 1 & 2. If you wrap them in quotes you will get the characters 'id' and 'lastName' instead of what id and lastName are set to.
To join or concatenate variables and text, your username line should read something like:
var userName = id + '#' + lastName;
You would also need to set the lastName to uppercase prior to joining the strings or you could chain it all together, though I haven't done this lesson so I don't know what is recommended.
var userName = id + '#' + lastName.toUpperCase();
// or
lastName = lastName.toUpperCase();
var userName = id+'#'+lastName;
I'm not sure of the exact syntax they are asking for, but if I look at fixing the 'app.js' so that it will run without errors, it should be something like:
var id = "23188xtr";
var lastName = "Smith";
id.toUpperCase();
lastName.toUpperCase();
var userName = id + '#' + lastName;
Sorry, without further understanding of the question this is all I can help.
Clint Dehner
8,808 PointsI tried that too ans still won't let me pass the 2nd task.
Damien Watson
27,419 PointsI have updated my answer above to modify the code you have shown in 'app.js' to remove errors. This is semantically correct, but it depends what the exact question is for what they are expecting.
Clint Dehner
8,808 Points@ Jason that worked good sir, thank you and Damien for the help.
Damien Watson
27,419 PointsDamien Watson
27,419 PointsSorry, first time posting... answer below.