DevToys icon indicating copy to clipboard operation
DevToys copied to clipboard

SpongeText implementation in Case Converter

Open AuburnMedia opened this issue 1 year ago • 1 comments

What improvement do you think would an existing feature or tool in DevToys?

Randomly transforms characters to uppercase or lowercase within the specified string.

Solution/Idea

Implementation in JS:

function spongeText(string) {
  const chars = string.split("");
  for (let i = chars.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * Math.floor(2));
    if (j == 0) {
        chars[i] = chars[i].toLowerCase();
    } else {
        chars[i] = chars[i].toUpperCase();
    }
  }

  return chars.join("");
}

Credit: Paul Seelman

Implementation in Python (available on PyPi): https://github.com/jwizzle/spongetext

Comments

No response

AuburnMedia avatar Feb 14 '24 23:02 AuburnMedia

I'd work on this if it's greenlit

ahrGNUts avatar Feb 28 '24 05:02 ahrGNUts