I am trying to split object into multiple objects. Here is how it looks. It is actually array of objects.
[
{
interval_9_gun_time_milliseconds: 0,
interval_9_net_time_milliseconds: 0,
interval_9_gun_pace: '00:07:04',
interval_8_gun_time_milliseconds: 0,
interval_8_net_time_milliseconds: 0,
interval_8_gun_pace: '00:07:04',
entry_id: 200
},
{
interval_9_gun_time_milliseconds: 0,
interval_9_net_time_milliseconds: 0,
interval_9_gun_pace: '00:02:04',
interval_8_gun_time_milliseconds: 0,
interval_8_net_time_milliseconds: 0,
interval_8_gun_pace: '00:04:04',
entry_id: 404
},
{
entry_id: 1
}
]
So expected result should be:
[
{
interval_9_gun_time_milliseconds: 0,
interval_9_net_time_milliseconds: 0,
interval_9_gun_pace: '00:07:04',
entry_id: 200
},
{
interval_8_gun_time_milliseconds: 0,
interval_8_net_time_milliseconds: 0,
interval_8_gun_pace: '00:07:04',
entry_id: 200
},
{
interval_9_gun_time_milliseconds: 0,
interval_9_net_time_milliseconds: 0,
interval_9_gun_pace: '00:02:04',
entry_id: 404
},
{
interval_8_gun_time_milliseconds: 0,
interval_8_net_time_milliseconds: 0,
interval_8_gun_pace: '00:04:04',
entry_id: 404
}
]
Bottom line split and group object by interval_{number} and add other props, if object doesn’t have interval remove it.