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

Can't get task two right

Hi,

I can't seem to get task 2 right on this one, tried and searched but haven't found it. Could someone please let me know where I went wrong?

BIG thanks in advance

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

var userName = id.toUpperCase('#', lastName.toUpperCase);

userName += id.toUpperCase + '#' + lastName.toUpperCase;
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

Dave Harker
PLUS
Dave Harker
Courses Plus Student 15,510 Points

Hi Emma Back,

You almost had it!! Just treat each requirement as a separate bit then use string concatenation to bring them together.

// You won't need every line of code here
// I'm just going to build it up with you (only last code line is required)

// To get the first challenge you just used variable.toUpperCase() method on the variable named id
var userName = id.toUpperCase() 

// Now we need to add a '#' symbol to the end of that (which is a string too) so now we'd have:
var userName = id.toUpperCase() + '#'

// The last requirement was to uppercase the lastName and add it to the end
// Using the same variable.toUpperCase() method idea that we used to complete challenge one
// Let's add that also and see the finished line of code you'd need to complete challenge 2.
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();  

I really hope that helped you out.
You basically already had it :smile: Nice work! and happy coding,
Dave :dizzy: