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 trial

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

eddie chen
eddie chen
3,790 Points

did I do something wrong that led to task one not passing?

Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName variable.

this is the task one, and I think i passed it, after finishing task 2, it always asks me to check task one, is there anything wrong with me code? Many thanks!

app.js
var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase();
var userName = lastName.toUpperCase();
userName =id+"#"+lastName;
index.html
<!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>

1 Answer

Steven Parker
Steven Parker
231,248 Points

Syntax errors cause the re-check to fail.

Variables should only be declared once, but you declared userName a second time. Also, instead of adding to it, you replaced the contents of userName first with the upper-cased last name, and then again with a concatenated string using the original lowercase names.

You've got the right bits there, but you need to re-arrange them. So instead of the last 2 lines you might write this:

userName += "#" + lastName.toUpperCase();
eddie chen
eddie chen
3,790 Points

thanks a lot, thats very helpful.