I have this:
products = [
{
'id': 1
'name: 'test'
},
{
'id': 2
'name: 'test'
},
{
'id': 3
'name: 'test'
}
... etc, etc
]
I need to restructure it to this:
products = [
row1: [
{
'id': 1
'name: 'test'
},
{
'id': 2
'name: 'test'
},
{
'id': 3
'name: 'test'
},
{
'id': 4
'name: 'test'
}
]
row2: [
{
'id': 5
'name: 'test'
},
{
'id': 6
'name: 'test'
},
{
'id': 7
'name: 'test'
},
{
'id': 8
'name: 'test'
}
]
row3: [.. etc, etc
]
the hard part is that the number of objects in each group is set using a variable (in this example the variable would be 4).
How can I achieve this using Typescript/Javascript? Its driving me mad!
Thanks