Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics Working with Strings Combine and Manipulate Strings

Riley O'Neil
Riley O'Neil
2,560 Points

what do we put on the .toUppercase line before the role?

i tried var & let but it didn't work, but i know we need something to activate the line, it can't just be by itself.

app.js
let firstName = "Carlos";
let lastName = "Salgado";
let role = 'developer';
var = role.toUpperCase();

msg = firstName + ' ' + lastName  + ':' + ' ' + role;
mouseandweb
mouseandweb
13,729 Points

Hello Riley,

When you call .toUpperCase() you can do this without declaring a new variable.

// declare a variable using let keyword
let role = 'developer';

// now that the variable role has been declared we can reassign
// its value without using let or var or any other keyword
role = role.toUpperCase();

// now the value assigned to role is 'DEVELOPER'

2 Answers

Riley O'Neil
Riley O'Neil
2,560 Points

i did that but it says 'The original string stored in role should not be modified.' Am I supposed to put something in the parenthesis?

mouseandweb
mouseandweb
13,729 Points

Hi Riley O'Neil ,

I just checked out the exercise. It had me create a new variable msg to hold the string containing firstName, lastName, and role.

The last step was to set the role variable to upper case. As you said, there is no need to reassign the value of role, we simply place role.toUpperCase() in place of role in the string concatenation.

// you had this:
let msg = firstName + ' ' + lastName  + ':' + ' ' + role;
// next you may add .toUpperCase() to role on the same line
let msg = firstName + ' ' + lastName  + ':' + ' ' + role.toUpperCase();

You have no need for this line:

var = role.toUpperCase();

That's because the variable var is not declared. It's also a reserved keyword. If you meant to place var keyword you missed the name for the variable that would follow before the = after var. Also, still no need for the line.

That leaves you with this:

let role = 'developer';
let msg = firstName + ' ' + lastName  + ':' + ' ' + role.toUpperCase();

Or, if you use string interpolation:

let msg = `${firstName} ${lastName}: ${role.toUpperCase()}`;
Riley O'Neil
Riley O'Neil
2,560 Points

ok, thank you so much! I wouldn't have known!