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

Having trouble with this question - what's wrong with my code?

Hey guys, - here is my code for this question -

' ' ' var id = "23188xtr"; var lastName = "Smith"; var id = lastName.toUpperCase(); var lastName += "#"

var userName = id.toUpperCase();

' ' '

app.js
var id = "23188xtr";
var lastName = "Smith";
var id = lastName.toUpperCase();
var lastName += "#"

var userName = id.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>
Samuel Webb
Samuel Webb
25,370 Points

I would highly recommend that you run through the JS Basics course again. This question means you don't have a complete grasp on the concepts of: creating variables, assigning values to variables and string concatenation. All three of these concepts are vital to JavaScript and It would probably be best to go back and make sure you have a solid understanding of these before moving on.

2 Answers

I must say, i got halfway through conditional statements and decided to start js over. Second time through is really helping.

Ramiro Martinez
Ramiro Martinez
13,858 Points

Try this, it works..

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