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

hello, needing assistance with uppercase strings.

I am asked to make one of my variables all uppercase, based on video examples and readings, I should have the code listed above, continue getting error messages, any suggestions?

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

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Raedawn,

The challenge is asking you to:

assign an all uppercase version of the id variable to the userName variable.

You are assigning userName to userName. This is a syntax error as you are trying to assign a variable that doesn't exist yet to a new variable. Remember that the right side of the assignment operator gets evaluated before the assignment itself. For example, in the line: var x = 1 + 1; x will be 2 because the 1 + 1 gets computed before assigning the result to the variable x.

In addition, it is id that you want to turn into uppercase, not userName.

Cheers

Alex

Gulshan Krishnagiri
Gulshan Krishnagiri
1,182 Points

var id = "23188xtr"; var lastName = "Smith"; var message = id + '#' + lastName; var userName = message.UpperCase();