Suppose I have an array as
let arr1 = [0,2] This is always sorted
Note: These elements in array represent indexes to be deleted from another array.
I have another array as:
let arrOvj = [1,4,6,7,21,17,12]
I want to delete element of arrObj, based on indexes present in arr1.
So after deletion expected OP should be,
[4,7,21,17,12].
So how can I achieve this.
I tried as:
for(let i=0;i<arr1.length;i++){
arrObj.splice(arr1[i],1)
}
But this is giving incorrect result.
Example: If arr1=[0]
It deletes first two elements instead of deleting element at index 0 of arrObj.
What other alternative can I follow so it deletes from provided index value only
Please let me know if anyone need any further information.