Reverse Titling

Published by bangyen in

The normal .titlecase function in Ruby on Rails capitalises the first letter of every word in a given sentence, leaving all the other letters as lowercase.

The goal of this challenge is to create a reverse_title() function, which achieves the complete opposite! Make the first letter of every word lowercase, and the rest uppercase!

Examples

reverse_title("this is a title") ➞ "tHIS iS a tITLE"

reverse_title("BOLD AND BRASH!") ➞ "bOLD aND bRASH!"

reverse_title("Elephants dance about bravely in Thailand") ➞ "eLEPHANTS dANCE aBOUT bRAVELY iN tHAILAND"

Notes

N/A

Watch a quick demo on how Edabit works.