JSFiddle - React, Tailwind, and code Playground
JavaScript
var groupBy = function(xs, key) {
return xs.reduce(function(rv, x) {
console.log(x)
(rv[x[key]] = rv[x[key]] || []).push(x);
return rv;
}, {});
};
console.log(groupBy(['one', 'two', 'three'], 'length'));