Hi everyone, I am currently trying to merge two arrays without having to use an apply to each loop as it is very inefficient.
I have my first array that looks something like this: [1,2,3,4,5,6,7,8,9,10]
And I have my second array that is an array of items: [{'ID': 3, 'data':'data3},{'ID': 5,'data':'data5'},{'ID': 6,'data':'data6'},{'ID': 8,'data':'data8'}}
And the resulting array needs to be something like: [1,2,{'ID': 3, 'data':'data3},4,{'ID': 5,'data':'data5'},{'ID': 6,'data':'data6'},7,{'ID': 8,'data':'data8'},9,10]
I managed to use a for loop and match each number to it's corresponding ID by checking if there is a valid id and if so update the array to include the item and if not just leave the number as is.
However I wonder if I can do this without using a for loop as it takes super long and is inefficient with larger data sets, I am open to ideas!
Thank you.