Very cool Ady. Yes, yours utilizes functional aspects of JavaScript better I agree. I somehow forgot that reduce
‘s accumulator can be an object literal not just an array 🤦♂
Oh man, I remember reading about snippets and never actually using them. Thanks Ady. I love it! Especially nice that you can save it off and later create a gist or similar. Very cool. Hey, so do you just use var
when you’re in snippet land? When I use let
or const
and then re-run I get the already defined error 😢Maybe you have a hot tip for me there haha.
I could be starting a debate over defensive vs. readable coding, but I would have done:
!!bag[coins] ? bag[coins] += 1 : bag[coins] = 1;
without the parentheses since there’s no real precedence confusion to worry about. Maybe that would have lost me the job though 😆
Really enjoyed this little digression and having a look over your github. Thanks for taking the time Ady!