Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

Lamarr Powell
Lamarr Powell
1,450 Points

Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName v

Need guidance for task 2, can someone explain?

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

var userName

var word = "javascript";
var userName = id; var shout = word.toUpperCase (JAVASCRIPT);
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

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Before we look at completing the challenge, let's look at your code for a moment. As you can see, you have two variable definition statements for the userName variable, and one is also missing a semi-colon to terminate the statement.

Start off by deleting both of these definition statements.

Now we can start over and create a new variable named userName and assign it the the value of the Id variable:

var userName = id;

Now, to convert the value of the Id variable to an all uppercase string, we need to use the toUpperCase method on it:

var userName = id.toUpperCase();

Now the userName variable holds an uppercase version of the string in the id variable. From your question, I have added an answer that you have asked, if this doesn't provide the correct code for the challenge, you would need to be more thorough with your question.

Hope this helps.