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

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Using String Methods

Elisha Schwabauer
Elisha Schwabauer
1,124 Points

Stuck 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'?

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

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

3 Answers

rydavim
rydavim
18,814 Points
var 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();

also... 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
Elisha Schwabauer
1,124 Points

Thank you so much..., that worked & made sense. I've been stuck here (embarrassingly) for days.

As 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.

var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUppercase +"#"+ lastName.toUpercase;

Like this. :)

Elisha Schwabauer
Elisha Schwabauer
1,124 Points

I tried that, & then I got "Oops! It looks like Task 1 is no longer passing." Any other ideas? (Thank you)

Elisha Schwabauer
Elisha Schwabauer
1,124 Points

Sorry Joel, I didn't realize what you were saying! Thank you!

Did you get it figured out? I'm glad to have helped.