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 trialRiley O'Neil
2,560 Pointswhat 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.
let firstName = "Carlos";
let lastName = "Salgado";
let role = 'developer';
var = role.toUpperCase();
msg = firstName + ' ' + lastName + ':' + ' ' + role;
2 Answers
Riley O'Neil
2,560 Pointsi 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
13,758 PointsHi 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
2,560 Pointsok, thank you so much! I wouldn't have known!
mouseandweb
13,758 Pointsmouseandweb
13,758 PointsHello Riley,
When you call .toUpperCase() you can do this without declaring a new variable.