Reverse Titling

Published by David Newman in

Your stereotypical titleCase() function in JavaScript might capitalize the first letter of every word in a given sentence, leaving all the other letters as lowercase.

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

Examples

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

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

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

Notes:

  • This was originally translated from a Python version of this question. Unfortunately, I forgot to write down the original question's URL, so if you spot it... let me know!
  • For extra credit (not really), convert the given function to a prototype method!
Watch a quick demo on how Edabit works.