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

I need help with this one ? where is the answers

I need some help with this challenge please. What I'm missing here.

app.js
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
lastName.toUpperCase();

userName += "#"+ LastName
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>
Mark Miller
Mark Miller
45,831 Points

The problem is in the line where you call toUpperCase() on lastName, because you are not assigning that to be the value of anything. So that line is just an expression, and its value is dropped when the processing moves to the next line. You have choices on how to fix it. You can assign the value of lastName.toUpperCase() to lastName by assignment with the = symbol. Or you can just one-line it on the userName assignment, which is best because the challenge does not say to permanently change lastName to upper case. So, use toUpperCase() in the same line where lastName is assigned to user name, all in one line.

1 Answer

Jason Wiram
Jason Wiram
42,744 Points

There are a couple things to note here.

  1. The last line of code in app.js uses LastName as a variable but the name of the variable created in the code is lastName.

  2. More importantly, when you call lastName.toUpperCase(); you are saving the result of that call anywhere. A possible solution would be to call lastName = lastName.toUpperCase(); Then if you updated your last line of code to use lastName it should work.