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 trialJames O'Brien
1,103 PointsOn my last nerve trying to get '#' between id and lastName. I've tried everything.
This seems so basic but I've tried every possible way to put '#' between id and lastName.
var userName = id + '#' + lastname.toUpperCase();
This seems like it would work but I still get the Bummer message. I've tried every different way and nothing works. I've even tried putting '#' into it's own variable and it doesn't work.
var id = "23188xtr";
id.toUpperCase();
var lastName = "Smith";
var userName = id + '#' + 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>
2 Answers
Jacob Moyle
6,150 PointsHi James,
While I haven't completed the current challenge you are working on, I suspect it may be because the id.toUpperCase();
isn't 'saving'. This is because when you call .toUpperCase();
it will return a new string but you are not saving the returned value to a variable.
On the other hand, the output of lastName.toUpperCase();
is being saved as part of the concatenated string to the variable named userName
.
I'm assuming that the expected output is "23188XTR#SMITH"
.
I'll add some comments and tweak the code you provided, to illustrate this:
var id = "23188xtr";
id.toUpperCase(); //=> Returns "23188XTR"
console.log(id); //=> prints "23188xtr"
var lastName = "Smith";
var userName = id + '#' + lastName.toUpperCase();
console.log(userName); //=> prints "23188xtr#SMITH" rather than "23188XTR#SMITH"
Cheers,
Jacob
James O'Brien
1,103 PointsThat was it! Thankyou! :)
Jacob Moyle
6,150 PointsAwesome! I'm glad to help!
I'm currently working through Tree House's career program, part of the process is to earn points on the forum through answer up-votes and 'best answers'.
It would be insanely helpful if you would be so kind to either up-vote and/or mark my answer as 'best answer'!
Cheers, Jacob