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

bug in challenge task 2 of 2

I put the line of code in the 1 task it tells me I pass than when I loads the 2 task I out the next line of code and it tells me oops task 1 is no longer working what am I doing wrong its om the variable challenge in javascript

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

var userName = id.toUpperCase( )+"#"+lastName.tpUpperCase( );
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

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,692 Points

Ho Jacob,

Sorry, there is no bug... but there is a syntax error in your code. That error almost always means that a syntax error was introduced into the current task you are working on, and that is what breaks the code checker.

If you look at the error message you are receiving when checking your code it will tell you exactly where:

There was an error with your code: TypeError: 'undefined' is not a function (evaluating 'lastName.tpUpperCase( )')

Here, it is saying the it was trying to evaluate the toUpperCase() method, but it came back as "undefined". This is because you have a typo in the method name. You have tpUpperCase(). If you correct the typo, the challenge will pass.

Also, on other note, it is not a good idea to put spaces in the parenthesis for the method. This could lead to issues down the line, as a space is a character, and if the method is not supposed to take any arguments, the space could be misread.
And on the topic of spaces, it is a good idea to space out the concatenation symbols. It's really hard to read the code when everything is smushed together:

var userName = id.toUpperCase() + "#" + lastName.toUpperCase();

Other than that, nice work! :) :dizzy: