let arr = [
{hash: "11223344", value: "abc"},
{hash: "11223344", value: "def"},
{hash: "22113344", value: "jkl"},
{hash: "22113344", value: "zyw"},
{hash: "33221144", value: "omn"},
{hash: "33221144", value: "xyz"}
];
let temparray = [];
let newarray = [];
arr.map((x) => {
var index = temparray.indexOf(x.hash);
if (index === -1){
temparray.push(x.hash);
newarray.push({ hash: x.hash, value: [x.value] });
} else {
newarray[index].value.push(x.value);
}
});
```
Last active
September 24, 2018 15:42
-
-
Save andrit/9ca35612fbeb612d32daa1585ff403f9 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment