I am trying to make function to get me difference of two 2D  arrays but I found that to make function removeArray() work it's required to take different counter variables in both function. If it's taken i  in both than loop iterate only once where it should iterate twice.
function removeArray(toremove, myarray){
      for(i=0; i< toremove.length ; i++){
          // console.log(getIndex(toremove[i],myarray));
          myarray.splice(getIndex(toremove[i],myarray),1);
          console.log("" + myarray); //only [2,3] will get remove
        }
    }
    
function getIndex(array, myarray){
      for(i=0;i< myarray.length ; i++){
          // if(typeof(array)== 'undefined'){console.log("error"); return 100;}
          if((myarray[i][0] == array[0]) && (myarray[i][1] == array[1])){
          return i;
          }
        }
    }
    var myarray=[[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4],[4,1],[4,2],[4,3],[4,4]];
    var toremove=[[2,3],[3,3]];
    
    removeArray(toremove,myarray);Also when commented parts are included(both together) i.e, // console.log(getIndex(toremove[i],myarray)) and  // if(typeof(array)== 'undefined'){console.log("error"); return 100}it iterates infinitely where it should have not more than twice.
Why is it so? Pls help. Thanks in advance!
 
     
     
    