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

Kevin Lewis
seal-mask
.a{fill-rule:evenodd;}techdegree
Kevin Lewis
Front End Web Development Techdegree Student 9,667 Points

Don't understand why this isn't working

Don't know what I'm missing in this statement.

app.js
var id = "23188xtr";
var lastName = "Smith";
alert( id .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>

2 Answers

Aaron Price
Aaron Price
5,974 Points

Three things

  1. you can't have a space between "id" and ".toUpperCase()"
  2. you need to assign the value of that to the userName variable.
  3. you don't need an alert
var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase()
Christopher Debove
Christopher Debove
Courses Plus Student 18,373 Points

Whitespaces are totally valid, ex:

var longVariableName = 'test';
var result = longVariableName
  .toUpperCase()
  .replace(/te/, "re");
Christopher Debove
PLUS
Christopher Debove
Courses Plus Student 18,373 Points

You need to affect the result of id.toUpperCase() to your variable userName :

var userName = id.toUpperCase();
Aaron Price
Aaron Price
5,974 Points

Whoops, you're right. I have no idea what I was thinking there.

Christopher Debove
Christopher Debove
Courses Plus Student 18,373 Points

It shocked me too at first. I'm used to see line breaks, but not "just" space or tabs here :o