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

Jerry Williamson
Jerry Williamson
378 Points

I am not sure why I get the message, "Oops! It looks like Task 1 is no longer passing."

is there something wrong with "id" variable or with my solution?

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

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

4 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Jerry;

  1. You need to reassign a value to userName, which 'userName + "#" + upperLast;` does not do.
  2. Using the code that Chris posted would work.
  3. You are using lastname in one location when it is defined as lastName elsewhere.
userName += "#" + upperLast;

That sets userName equal to itself with the concatenated addition of the reset of the code.

Ken

Ken Alger
Ken Alger
Treehouse Teacher

You could also do something like:

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();

and take out the creation of another variable entirely.

Ken

Chris Shaw
Chris Shaw
26,676 Points

Hi Jerry,

You appear to have a minor syntax error in the last line of your code, instead of += after the hash you should have a single plus sign.

userName += "#" + uplast;
Jerry Williamson
Jerry Williamson
378 Points

Thanks, Chris, for the speedy reply! I still get the error "Oops! It looks like Task 1 is no longer passing." with this code.

var id = "23188xtr"; var lastName = "Smith";

var userName = id.toUpperCase(); var upperLast = lastname.toUpperCase(); userName + "#" + upperLast;

My error somewhere?

Jerry Williamson
Jerry Williamson
378 Points

Awesome. Makes great sense and I thank you for the help!