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

Do I need to create a new variable in order to manipulate an existing value into all upper case letters?

This is challenge three on manipulating and transforming strings.

Thank you, Jasper!

Jasper Peijer
Jasper Peijer
45,009 Points

No problem, just make sure to mark the post as answered if it helped out. :)

Steven Parker
Steven Parker
231,248 Points

FYI: Answers can be marked and voted on, but not comments.

Jasper Peijer
Jasper Peijer
45,009 Points

Oh my bad, I didn't even realize the difference until now

1 Answer

Jasper Peijer
Jasper Peijer
45,009 Points

There's a few options you have here:

You could call the uppercase function when initializing the variable:

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

You could reinitialize the variable like this:

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

You could put the uppercase version into a new variable:

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

Or you could call the upper case function while initializing msg:

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

The last one is most likely to pass the code challenge