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
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsJavaScript Basics - "Concatenation" Challenge Task 2 of 2
Can someone tell me where I am going wrong? Below is the assignment, the "bummer" response and my code.
HERE IS THE ASSIGNMENT
Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".
THIS IS THE RESPONSE FOR MY CODE.
Bummer! The userName variable is "23188xtr#SMITH" not "23188XTR#SMITH".
THIS IS MY CODE
1 var id = "23188xtr"; 2 var lastName = "Smith"; 3 document.write(id.toUpperCase()); 4 var userName = id+"#"+ lastName.toUpperCase();
2 Answers
Daniel Gauthier
15,000 PointsHey Carleen,
I found the challenge you were having trouble with and ran through it quickly.
I've included a breakdown below, but the two issues you were running into were:
You were trying to use document.write() when the challenge was not asking for one (this challenge is focused on the assignment of variables, not displaying the values)
The second part of the challenge asked you to add onto the assignment you completed in step one, which means you just add the requested code to the existing assignment instead of making a new assignment.
The first part of the challenge asks:
Assign an all uppercase version of the id variable to the userName variable.
Which passes once you have the following code:
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase();
Then the second part asks:
Complete the assignment to the userName variable by adding a # symbol followed by an all uppercase version of the lastName variable. In other words, using string concatenation so that the final value of userName is "23188XTR#SMITH".
Which will pass once you have the code set up as below:
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Good luck with the course!
Carleen Hall
Front End Web Development Techdegree Student 3,158 PointsThanks Daniel.
Daniel Gauthier
15,000 PointsDaniel Gauthier
15,000 PointsGoing to throw this here in case you ever have to post code in the future :D
How to Post Code on the Forums
There are two ways to share your code on the forums here, excluding using external tools from outside of Treehouse.
Method One
The first method is to use a series of three ` (backticks, located at the top left of the keyboard) without any spaces on one line, paste all of your code starting on the second line, then closing the code block with a second series of three backticks. Take a peek at the link for the "Markdown Cheatsheet" located above the "Post Answer" button anytime you're about to post a comment or answer. Using this method, the code will look like this:
```css
(code here)
```
Method 2
The second method is a little more convoluted, but it lets us look at your entire project and make our own copy to try fixing issues. I'll order the steps since it can be a little confusing the first time around:
Open the workspace you're having trouble with.
On the menu bar located to the left of the "Preview Workspace" button is the "Snapshot Workspace" (camera icon), click that.
A popout will appear with another button that says "Take Snapshot", click that.
It should create a new snapshot, which will appear beneath the "Take Snapshot" button in the popout. Click the snapshot you want to share.
The snapshot should open a new browser tab. Highlight the url in the snapshot's browser tab (it should look like this: https://w.trhou.se/duckyj79b1i0 ).
Create your forum post and paste the snapshot's url into the post. Other Treehouse users will be able to open the snapshot, then 'fork' a new copy to check out your code.
Keep in mind that you can only ever have five snapshots, but you can delete them by hovering over the snapshot located below the "Take Snapshot" button in the popout and clicking the trash bin icon.
Good luck!
Sean Fitzgerald
3,466 PointsSean Fitzgerald
3,466 PointsThank you for this. I spent more time than I'd like to admit because with task 1, you do the id.toUpperCase with a semi colon and then do the concatenation in the second task. I had it typed right the entire time but never removed the first semi colon. Thanks for saving my sanity.