Does anyone know how to group object of arrays to a new array of object arrays based on its index with Javascript? I'm quite new to this so I'm quite stuck here
For example I have this object :
{
'first': [
{
name: 'jimmy',
text: 'I love you'
},
{
name: 'jimmy',
text: 'I miss you!'
},
{
name: 'jimmy',
text: 'I hate you!'
}
],
'second': [
{
name: 'jeremy',
text: 'Wow'
}
],
'third': [
{
name: 'john',
text: 'You ugly'
},
{
name: 'john',
text: 'You handsome'
},
{
name: 'john',
text: 'you beautiful'
}
],
'fourth': [
{
name: 'tom',
text: 'this is cool!'
},
{
name: 'tom',
text: 'this is hard'
}
]
}
which I want to transform to something like :
[
[
{
name: 'jimmy',
text: 'I love you'
},
{
name: 'jeremy',
text: 'Wow'
},
{
name: 'john',
text: 'You ugly'
},
{
name: 'tom',
text: 'this is cool!'
},
],
[
{
name: 'jimmy',
text: 'I miss you!'
},
{
name: 'john',
text: 'You handsome'
},
{
name: 'tom',
text: 'this is hard'
}
],
[
{
name: 'jimmy',
text: 'I hate you!'
},
{
name: 'john',
text: 'you beautiful'
}
]
]
so 'first'[1],'second'[1], 'third'[1], 'fourth'[1] should group to the first array as array of objects and 'first'[2],'second'[2], 'third'[2], 'fourth'[2] should go to the second array as array of objects and so on..