63

Home baked.

Comments
  • 4
    Not sure if image is not appearing because my internet is bad or your home backed thingy is really messed up
  • 14
    That variable declared globally and used inside a function made me shudder
  • 16
    This is my implementation:

    const spongebobCase = str => str.toLowerCase().split('').map(x => Math.random() < 0.5 ? x.toLowerCase() : x.toUpperCase()).join('')
  • 4
  • 3
    @crisz impure function inside a map reeeeeee

    jk, good stuff
  • 1
    You should add a time day to add entropy to the math.random function, because if I'm not mistaken, it relies on time
  • 4
    @crisz well if you wanna go all fancy at least use the spread operator instead of split ;)
  • 2
    @musician good point ahaha
  • 0
    @RantSomeWhere no, it's supposed to be arbitrary
  • 0
    I love it🤓
  • 2
    After 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('');
  • 0
    @crisz how about using `reduce` instead of `map` and `join`? ^^
  • 1
    @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'](), '');
  • 0
    Also, why lowercase the string at the beginning of you're gonna recase it anyway later?
Add Comment