Learn Ruby Course - Capitalization

I started the Learn Ruby Course today, and on the part where you capitalize the city name in the beginning, I can’t figure out how to capitalize both words in the city name. (My city name has two words in it.) Is there a command that lets you capitalize A CERTAIN PART of the variable?

Something like:

randomString = “hello world”
randomStringCapitalized = randomString.capitalize[7]

If anyone finds a way to do this, please tell me!

1 Like

Split it and then join it back after? Watch out if separated by anything other than space because you will then change the delimiters when joining it back together. If that’s the case either work it out yourself (it’s not that involved, refer to how you would do it manually) or find a gem that does it for you (google is your friend)