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

peterson st gourdain
peterson st gourdain
931 Points

whats wrong

I'm I using it right

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

var userName.toUpperCase("xtr");
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

Elad Ohana
Elad Ohana
24,456 Points

Hi Peterson,

The method .toUpperCase() will convert whatever string it's called on. So in your case, it will attempt to return the result of userName but with all letters are in upper case. Since userName is not given any value at first, it will not recognize what needs to be altered.
Keep in mind that this method does not alter the actual value of the variable, it simply asks it to provide a result with the string in upper case, leaving the value the same. Here is an example:

var lastName = "Smith" //lastName == "Smith"
lastName.toUpperCase() // returns the value "SMITH" which is lastName in upper case, but still the value of lastName is still "Smith"
var lastNameUpper = lastName.toUpperCase() // gives the value of "SMITH" to lastNameUpper, but keeps the variable lastName with the value of "Smith"

Hope this helps.

Elad