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 trialHamed Ali
5,626 PointsJS Basics Challenge: Working With Strings
The question doesn't define what the output format should be. A var or an alert or document.write?
Anyone have any ideas why I am getting the error below?
var id = "23188xtr";
var lastName = "Smith";
var userName = (id.toUpperCase());
// this part was my successful answer to Challenge Task 1:
// Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName variable
// Second Challenge is:
// add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".
alert(userName + "#" + lastName.toUpperCase() ) ;
// I get this error:
// The `userName` variable is "23188XTR" not "23188XTR#SMITH"
<!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>
3 Answers
Mike Ziethlow
60 PointsYou might be jumping ahead of what it's asking for. It's not asking for an alert. It's only asking for the variable to be altered so that id and lastName are combined with a "#" in the middle and saved to the userName variable.
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
Hamed Ali
5,626 Points@Mike - I tried that initially and it didn't work. So thats when I tired to do an output of some sort.
Mike Ziethlow
60 PointsThat code above passes now, right? Let me and future users know if it doesn't.
Hamed Ali
5,626 Pointsyes it works great Mike - thanks ;-)
Mike Ziethlow
60 PointsNo prob!