re: Javascript Sock Merchant Challenge - Solution 2 VIEW POST

re: I don't think you even need the last reducer. Just keep a running counter. function sockMerchant(n, ar) { const colors = {} let pairs = ...

Another hilarious one:

function sockMerchant(n, ar) {
    const colors = {}
    let pairs = 0;
    for (const color of ar) pairs += !(colors[color] = !colors[color])

    return pairs;

... and just when I thought it could not get better...


MM has come up with some JS wizardry here ... flipping those 1's and 0's ... I would'nt have come up with it myself, but hats off to him; it's a cracker!

I wonder if he plays code golf?

Oh! how cool is that!

I could watch that all day in fullscreen mode, but I wouldn't get anything else done.

Cheers for sharing.

It's surprisingly calming and on my big screen monitor truly awesome indeed

Oh! now your just boasting Ady ... how big?

Would be an excellent screen saver; don't you think?

boasting lol :) I've converted a 40" flat screen tv into a monitor. the image quality is exquisite and yes a great screen saver

Oh my!

That's what I would call ... total immersion!

code of conduct - report abuse