DevToys
DevToys copied to clipboard
SpongeText implementation in Case Converter
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
I'd work on this if it's greenlit