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 trialGena Israel
2,047 PointsWhy is the error task 1 is no longer passing?
i am not sure what i did wrong I tried using the += javascript code for this challenge...
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase()
userName += # + 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
Jennifer Nordell
Treehouse TeacherHi there, Gena! The reason it's saying that task 1 is no longer passing is because you've introduced a syntax error in your code. It doesn't understand what the hashtag is because you haven't enclosed it in quotation marks. There are a couple of ways to fix this. Using your code it could look like this:
var userName = id.toUpperCase()
userName += "#" + lastName.toUpperCase()
Or another, possibly more elegant way to do it would be to do this:
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
As a side note, JavaScript doesn't require you to end your statements in a semicolon as it has functions that can help do that for you. However, this can lead to ambiguous statements in the long run. It's considered best practice to end all statements in a semicolon.
Hope this helps!
Nando Delgado
7,157 PointsAre you just trying to concatenate both strings into upper case first and last name? It's your number sign that was giving you an error.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase()
userName += " " + lastName.toUpperCase()
Gena Israel
2,047 Pointsno, the challenge is Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".
so i thought i needed # sign
ve
5,048 PointsYou forgot to put a semicolon on the end of each line.
Plus, you're missing the quote marks around your #:
userName += "#" + lastName.toUpperCase();
Gena Israel
2,047 Pointsstill not passing