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
-
crisz82365yThis is my implementation:
const spongebobCase = str => str.toLowerCase().split('').map(x => Math.random() < 0.5 ? x.toLowerCase() : x.toUpperCase()).join('') -
djlazz313765yYou should add a time day to add entropy to the math.random function, because if I'm not mistaken, it relies on time
-
musician9425y@crisz well if you wanna go all fancy at least use the spread operator instead of split ;)
-
crisz82365yAfter 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(''); -
crisz82365y@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'](), ''); -
djlazz313765yAlso, why lowercase the string at the beginning of you're gonna recase it anyway later?
Home baked.
joke/meme