const data = [
{name:'Apple', order:1, path:'0'}
{name: 'Orange', order:2, path:'1'}
{name: 'Banana', order:3, path:'2'}
{name: 'Grape', order:4, path:'3'}
]
const newObj = {name: 'Mango', order:3, path:'2'}
I want to insert the new object data in the 'data' array in between the 'Orange' - 'Banana' and also change the order values and path values based on the new object order and path value.
I mean based on the new object path and order value the new object will insert the correct position.
the answer is like below:-
const data = [
{name:'Apple', order:1, path:'0'}
{name: 'Orange', order:2, path:'1'}
{name: 'Mango', order:3, path:'2'}
{name: 'Banana', order:4, path:'3'}
{name: 'Grape', order:5, path:'4'}
]
I tried this solution but I want to increase my object order and path count.