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 trialElisha Schwabauer
1,124 PointsStuck on challenge task 2 of 2, JS, Storing & Tracking Info w/ Variables
I've tried a few different ways of writing this & I keep getting 'Bummer! Did you add the '#' character between 'id' and 'lastName'?
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase("id"+"#"+"lastName");
<!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>
3 Answers
rydavim
18,814 Pointsvar id = "23188xtr";
var lastName = "Smith";
// Right now this is concatenating the string "id" and the string "lastName", instead of their values.
// Remember, you're calling the toUpperCase() method on the variable before the '.' only.
var userName = id.toUpperCase("id"+"#"+"lastName");
var id = "23188xtr";
var lastName = "Smith";
// You want to manipulate and concatenate the values of the variables. No quotes allowed!
var userName = id.toUpperCase() + "#" + lastName.toUpperCase();
Joel Smith
14,779 PointsAs it sits, JS thinks you're trying to use the strings "id" and "lastName", but you and I know that you really mean the variables with those names..
Remove the quotes from your variables.. this will solve your issue.
Joel Smith
14,779 Pointsvar id = "23188xtr";
var lastName = "Smith";
var userName = id.toUppercase +"#"+ lastName.toUpercase;
Like this. :)
Elisha Schwabauer
1,124 PointsI tried that, & then I got "Oops! It looks like Task 1 is no longer passing." Any other ideas? (Thank you)
Elisha Schwabauer
1,124 PointsSorry Joel, I didn't realize what you were saying! Thank you!
Joel Smith
14,779 PointsDid you get it figured out? I'm glad to have helped.
Elisha Schwabauer
1,124 PointsYes, thank you!
Joel Smith
14,779 PointsJoel Smith
14,779 Pointsalso... this is correct. I totally missed that you need to call the method .toUppercase on each variable. Do as rydavim says. :)
Good answer rydavim!
Elisha Schwabauer
1,124 PointsElisha Schwabauer
1,124 PointsThank you so much..., that worked & made sense. I've been stuck here (embarrassingly) for days.