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

Stevie Fortune
Stevie Fortune
2,677 Points

I can't see what I am doing wrong with this task. Please help!

I can't work out what I am missing in my code to complete the task. It's probably something simple, but its driving me crazy!

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

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

1 Answer

andren
andren
28,558 Points

You are missing parenthesis following the toUpperCase function call. In JavaScript if you don't use parenthesis then the function will not be executed, instead JavaScript will simply reference the function. Meaning that it returns the function itself instead of the result of calling the function. It's also worth mentioning that while it is not invalid it's rare to have a space between the method name and the parenthesis like you have for the toUpperCase function. If you fix the issue like this:

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

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

Then your code will pass.

Stevie Fortune
Stevie Fortune
2,677 Points

Awesome! Thanks Andren for explaining this. It makes a bit more sense to me now. Appreciate your help!