I have data something like this
const data = [
{
name: 'name1',
id: 'id1'
},
{
name: 'name2',
id: 'id2'
},
{
name: 'name3',
id: 'id3'
},
{
name: 'name4',
id: 'id4'
},
{
name: 'name5',
id: 'id5'
},
{
name: 'name6',
id: 'id6'
},
{
name: 'name7',
id: 'id7'
},
{
name: 'name8',
id: 'id8'
},
]
i need to push all objects up to id3 (not include id3) into one array and from id3 to id6 (not inclue id6) into one array, rest of things into another array.
between id1 and id3 any number of objects will add but we need to push until id3, same way we can add number of objects into id3 to id6.
finally i try to achieve like this
firstArr = [
{
name: 'name1',
id: 'id1'
},
{
name: 'name2',
id: 'id2'
}
]
secondArr = [
{
name: 'name3',
id: 'id3'
},
{
name: 'name4',
id: 'id4'
},
{
name: 'name5',
id: 'id5'
}
]
thirdArr = [
{
name: 'name6',
id: 'id6'
},
{
name: 'name7',
id: 'id7'
},
{
name: 'name8',
id: 'id8'
}
]
here the order like id3 and id6 won't change so that we can take this as reference.
id1,id2,anyId,anotherId,id3,id4,something,id6,id7should be split this way:id1,id2 | anyId,anotherId,id3,id4,something | id6,id7?