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 trialJacob Trevino
976 Pointsbug 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
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase( )+"#"+lastName.tpUpperCase( );
<!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
Treehouse Moderator 145,860 PointsHo 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! :)