Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Not sure if image is not appearing because my internet is bad or your home backed thingy is really messed up
-
crisz81916yThis is my implementation:
const spongebobCase = str => str.toLowerCase().split('').map(x => Math.random() < 0.5 ? x.toLowerCase() : x.toUpperCase()).join('') -
djlazz313696yYou should add a time day to add entropy to the math.random function, because if I'm not mistaken, it relies on time
-
musician6656y@crisz well if you wanna go all fancy at least use the spread operator instead of split ;)
-
crisz81916yAfter the success of v1, here is the v2:
const spongebobCase = str => [...str.toLowerCase()].map(x => x['to'+(Math.random() < 0.5 ? 'Lower': 'Upper') + 'Case']()).join(''); -
crisz81915y@Wack you are right, here is v3:
const spongebobCase = str => [...str.toLowerCase()].reduce((x,y) => x+y['to'+(Math.random() < 0.5 ? 'Low': 'Upp') + 'erCase'](), ''); -
djlazz313695yAlso, why lowercase the string at the beginning of you're gonna recase it anyway later?
Home baked.
joke/meme