AlTeRnAtInG cApS

Published by Pustur in

Create a function that alternates the case of the letters in a string (known as Spongecase).

Examples

alternatingCaps("Hello") ➞ "HeLlO"

alternatingCaps("How are you?") ➞ "HoW aRe YoU?"

alternatingCaps("OMG this website is awesome!") ➞ "OmG tHiS wEbSiTe Is AwEsOmE!"

Notes

  • The first character should always be UPPERCASE.
  • Ignore spaces.
Watch a quick demo on how Edabit works.