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

Jack Edmonds
Jack Edmonds
2,466 Points

it says task 1 is no longer passing. what do I do

it says task 1 is no longer passing

app.js
var id = "23188xtr";
var lastName = "Smith";
+
var userName = '23188XTR#SMITH'.toUpperCase( );
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>
Brian Besler
Brian Besler
11,493 Points

It will go through if you put:

var userName = "23188xtr#Smith".toUpperCase();

1 Answer

Austin Whipple
Austin Whipple
29,725 Points

Hi, Jack:

First a heads up: The warning that a previous task is no longer passing doesn't necessarily mean you broke the answer to the first task, but could mean that the entire script is invalid due to changes you've made in an attempt to answer the second task.

Now on to the tasks!

You and Brian are choosing to copy and paste the variables together into the JavaScript. However, the idea here is to make JavaScript do the combinations in case the variables are changed down the road. If the variables change, but the code uses only variable names instead of values, you don't have to update any of the functional parts of your code.

For instance, you can add characters to the end userName variable using the + operator to concatenate. So to add the hash character to the end, you'd do:

userName = userName + '#';

Or you can shorten that further by doing:

userName += '#';

And to extend that to adding the last name, you can combine the concatenation with the .toUpperCase() method you've already used on the lastName variable. Give it a shot and see how it goes!