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

saisindhoorreddy palla
saisindhoorreddy palla
1,146 Points

i got following problem

i need the code and what is thee problem plz?

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

 var userName= id.toUpperCase();
 var userName= userName+'#'+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>
Gustavo Winter
Gustavo Winter
Courses Plus Student 27,382 Points

check this line:

var userName= userName+'#'+LastName.toUpperCase();

Var cant start with capitalized letters

2 Answers

Juan Luna Ramirez
Juan Luna Ramirez
9,038 Points

Javascript is case sensitive. You have LastName when it should be lastName.

This is a ReferenceError since LastName with capital L does not exist.

Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

Gustavo Winter please don't introduce false informations.

Variables can start with uppercase letter, the problem is that his variable was named "lastName" and variable names are case sensitive.

Gustavo Winter
Gustavo Winter
Courses Plus Student 27,382 Points

Christopher Debove Sorry, i dont want to introduce false informations. But until know variables cant start with uppercase letter. The same for start with numbers.

but, if its possible, thank you for correct me and sorry for the false information.

Christopher Debove
Christopher Debove
Courses Plus Student 18,373 Points

To be more precise, variables name are written in lower camel case by convention. But starting a variable name with an uppercase character is valid.

Those are all valid in JS :

myVariable1
MyVariable1
$myVariable1
_myVariable1

Those are not valid :

%myVariable
my%Variable
1myVariable