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
var newCells = [];
for (var i = 0; i < totalCells.length; i++) {
var lineNumber = totalCells[i].lineNumber;
if (!newCells[lineNumber]) { // Add new object to result
newCells[lineNumber] = {
lineNumber: lineNumber,
cellWidth: []
};
}
// Add this cellWidth to object
newcells[lineNumber].cellWidth.push(totalCells[i].cellWidth);
}