Original was from Reduce Advanced of funfunfunction. It was a great example, but I thought it could use a bit more of the ES6 goodness like template literals, destructuring, and the spread operators.
Also the reduced form is a more "pure" functional implementation since it doesn't mutate the original object with evil functions like push
, but instead returns new data every time. A JS Bin is available to run and play with the modified version.