JSFiddle - React, Tailwind, and code Playground

by thefourtheye

JavaScript

var data = [{
    "name": "jim",
        "color": "blue",
        "age": "22"
}, {
    "name": "Sam",
        "color": "blue",
        "age": "33"
}, {
    "name": "eddie",
        "color": "green",
        "age": "77"
}];

var result = _.chain(data)
    .groupBy("color")
    .pairs()
    .map(function (currentItem) {
        return _.object(_.zip(["color", "users"], currentItem));
    })
    .value();
console.log(result);