I have an array with repeating values:
[ ['Deer Skin', 1], ['Bear Skin', 1], ['Deer Skin', 1], ['Cougar Skin', 2] ... ]
I want to compare them by the sting value of index[0]
and remove duplicates while storing the result in a new object.
The resulting values would look like:
[ {name: 'Deer Skin', quantity: 4}, {name: 'Bear Skin', quantity: 5}, {name: 'Cougar Skin', quantity: 4} ... ]
I'm not entirely sure how to proceed from here. Right now I have an array of objects with all initial duplicate array values removed:
[
{name: "Deer Skin", quantity: 0}
{name: "Bear Skin", quantity: 0}
{name: "Cougar Skin", quantity: 0}
...
But I'm not understanding how I can map the values of:
[ ['Deer Skin', 1], ['Bear Skin', 1], ['Deer Skin', 1], ['Cougar Skin', 2] ... ]
to above object.