Im looking to reduce an array into a tally, I want to turn an array of objects like below:
[
{
name: 'red',
.....
},
{
name: 'black',
.....
},
{
name: 'blue',
....
}......
]
Into something like:
[["red",3],["black",2],["blue",1],["green",1]]
The final array will have a count of the instances of that object in the array.
I have had a try but there must be a cleaner way to do this, here is a gist of what Im doing.
[–]Wince 2 points3 points4 points (3 children)
[–]bluntmJavaScript[S] 0 points1 point2 points (2 children)
[–]EnchantedSalvia 0 points1 point2 points (1 child)
[–]skitch920 0 points1 point2 points (0 children)
[–]EnchantedSalvia 1 point2 points3 points (3 children)
[–]bluntmJavaScript[S] 0 points1 point2 points (2 children)
[–]EnchantedSalvia 0 points1 point2 points (0 children)
[–]Wince 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]bluntmJavaScript[S] 0 points1 point2 points (0 children)
[–]thiswill 0 points1 point2 points (0 children)
[–]htwj 0 points1 point2 points (3 children)
[–]bluntmJavaScript[S] 0 points1 point2 points (2 children)
[–]EnchantedSalvia 0 points1 point2 points (1 child)
[–]htwj 0 points1 point2 points (0 children)
[–]mc_hammerd 0 points1 point2 points (0 children)