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 Making Decisions in Your Code with Conditional Statements Introducing Conditional Statements

1,775 Points

if i want to make only for example the first and the last letter in uppercase mode ..how can i do that ?

if i want to make mercury into all uppercase .. i shall use the toUppercase method. But, how about if i only want to make the first "r" and the "u" (in mercrury) into uppercase while letting all the other letters in lowercase ?

1 Answer

Here's a way I came up with:

let answer = "mercury"

let changed = answer[0].toUpperCase() + answer.slice(1, answer.length - 1) + answer[answer.length - 1].toUpperCase()


There might be a better way to do it. Let me know if this helps!