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

Just not getting it...

Q: Finally, add a # symbol and lastName in uppercase to the end of the userName string. The final value of userName is "23188XTR#SMITH".

I'm typing all kinds of stuff, even 'id' + 'lastName'

23188xtr#Smith - without the # - #lastName - ETC.

JavaScript is finicky

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

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

4 Answers

It's trying to show you how to concatenate a string. So you join two strings together with the + operator. It wants you to have a pound sign between id and lastname. So essentially you have to 'add' all three of those values.

edit: Also, '#lastName' will be printed out as literally '#lastName'. You need to use the variable, lastName and the string of '#'.

I'm not getting it

after (id.toUpperCase()) I'm writing:

  • 'id' + '#' + 'lastName';

'id' + 'lastName';

'id' + '#' +'lastName';

I'm not getting it. Am I putting too many + or not enough spaces or too many spaces?

You're writing strings instead of variables that hold strings. if var name = 'Christopher'

name === 'name'.//false

name === 'Christopher'//true

'name'==='name'//true

Is it 'id' + '#' + 'lastName'

or

'id' + '#lastName' ???

It’s id + β€˜#’ + lastName with toUpperCase on the variables

Yeah, I actually just figured it out

I wrote:

  • '#' + (lastName.toUpperCase)); and it worked

thanks Ruben