Hi all, i'm trying to do this, I have an array that looks like this:
[ { rId: { id: '123455667' },
form: 'layer',
timeStamp: '2015-11-20T10:28:26-03:00',
exa: '32144B5A0000200000000001' },
{ rId: { id: '123455667'},
form: 'item',
timeStamp: '2015-11-20T10:28:28-03:00',
exa: '30142F13F0138D0000000057' },
{ rId: { id: '123455667' },
format: 'item',
timeStamp: '2015-11-20T10:28:27-03:00',
exa: '30142F13F0138D0000000054' },
{ rId: { id: '123455667' },
format: 'layer',
timeStamp: '2015-11-20T10:29:09-03:00',
exa: '32144B5A00002000000001AB' },
{ rId: { id: '123455667' },
form: 'item',
timeStamp: '2015-11-20T10:30:19-03:00',
exa: '30142F13F0138D0000000055' } ]
And I want to create to separete arrayas that look likes:
[ { rId: { id: '123455667' },
form: 'layer',
timeStamp: '2015-11-20T10:28:26-03:00',
exa: '32144B5A0000200000000001' },
items: [
{ rId: { id: '123455667'},
form: 'item',
timeStamp: '2015-11-20T10:28:28-03:00',
exa: '30142F13F0138D0000000057' },
{ rId: { id: '123455667' },
format: 'item',
timeStamp: '2015-11-20T10:28:27-03:00',
exa: '30142F13F0138D0000000054' }
]
]
[ { rId: { id: '123455667' },
format: 'layer',
timeStamp: '2015-11-20T10:29:09-03:00',
exa: '32144B5A00002000000001AB' },
items: [
{ rId: { id: '123455667' },
form: 'item',
timeStamp: '2015-11-20T10:30:19-03:00',
exa: '30142F13F0138D0000000055' }
]
]
So in simple words, if there are two elements with format layer add elements with format item to the first element with format layer and those who are after the second layer to the second layer, and in the event that there is only one layer add all items formatted items to that layer
This may be silly but do not know where to start.
Thanks.