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 Working with Strings Combine and Manipulate Strings

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,758 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

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,758 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()}`;

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