Hello I want to merge a array based on the unique item in the array.
The object that I have
totalCells = []
In this totalCells array I have several objects like this
totalCells = [
{
cellwidth: 15.552999999999999,
lineNumber: 1
},
{
cellwidth: 14,
lineNumber: 2
},
{
cellwidth: 14.552999999999999,
lineNumber: 2
},
{
cellwidth: 14,
lineNumber: 1
}
];
Now I want to make a array where I have combination of array based on the lineNumber.
Like I have a object with lineNumber property and cellWidth collection. Can I do this ?
I can loop through each row and check if the line number is same and then push that cellwidth. Is there any way that I can figure ?
I'm trying to get an output like this.
totalCells = [
{
lineNumber : 1,
cells : [15,16,14]
},
{
lineNumber : 2,
cells : [17,18,14]
}
]
Do you mean something like this?
What about something like this :
Hope this helps!