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

ASHLEY HAYES
ASHLEY HAYES
8,646 Points

Adding to a string

The first question asked to declare a variable and turn the string into uppercase. var userName = id.toUpperCase(); var userName

The next step asks you to add "#" and the variable lastName to the end of the username string.

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

I keep running into an error and cannot figure out how to get the variable userName to return the id number plus "#" plus lastName in all uppercase.

app.js
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase + "#" + lastname.toUpperCase();
var 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>

3 Answers

Abraham Juliot
Abraham Juliot
47,353 Points

You got this. Just a typo and a redeclaration not needed at the end

var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + "#" + lastName.toUpperCase(); // note, lastName with a capital N
// no need to redeclare var userName; at the end as that would make userName a null value;
ASHLEY HAYES
ASHLEY HAYES
8,646 Points

I've tried that answer and it keeps telling me that my task1 is no longer passing. Which was declaring userName with just the id and .toUppercase method. So confused!

Abraham Juliot
Abraham Juliot
47,353 Points

sorry, forgot to mention make sure to include parenthesis () to both toUpperCase methods.

I've been coding for years, and I make that mistake frequently on the toUpperCase() method. :)

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

remove your last line of code