Hello I want to merge a array based on the unique item in the array.
The object that I have
totalCells = []
In this totalCells arr
What about something like this :
totalCells.reduce(function(a, b) { if(!a[b.lineNumber]){ a[b.lineNumber] = { lineNumber: b.lineNumber, cells: [b.cellwidth] } } else{ a[b.lineNumber].cells.push(b.cellwidth); } return a; }, []);
Hope this helps!