AlTeRnAtInG cApS

Published by Николай 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 letter should always be UPPERCASE.
  • Ignore spaces.
Watch a quick demo on how Edabit works.