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

Ileana Dell'Unti
Ileana Dell'Unti
2,282 Points

i receive the message of the page with the complete sentence write well but the keeps saying that # symbol is not there!

don't understand : (

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


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

5 Answers

Hey ! You have to call the uppercase method in both cariables, ( Id + lastname )

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

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

You most welcome :)

Ileana Dell'Unti
Ileana Dell'Unti
2,282 Points

so it's just + with variables, so when do I use += ?

the "+=" is used when you want to increment the same variable by choosen number, given exemple :

var i = 10;
i += 10;  // this is the equivalent sentence to this i = i + 10;
alert(i);  // this will give you 20 as result, since i had 10 as value at the begning and then we added an other 10 to it.

it is used as a shorthand !

Ileana Dell'Unti
Ileana Dell'Unti
2,282 Points

thanks!! get a bit confuse some times :P