4 Replies Latest reply on Feb 26, 2014 2:21 AM by Peter Kahrel

    How to remove set of item values of array from another array in Javascript

    vimal_indesign

      var myFind_collections =[3,6,10,234,235,236,237,238,239,240,241,244,245,246,247,248,248,249,250];
      var pgRangeCollection = [234,235,236,237,238,239,240,241,244,245,246,247,248,248,249,250];

      for(v=0;v<=pgRangeCollection.length;v++){
         
      var pgMatch = pgRangeCollection[v];
          clear_pg_range
      (pgMatch);
         
      }

      function clear_pg_range(pgMatch){
             
      //for(d=0;d<=myFind_collections.length-1;d++){
             
      for(d=0;d<=myFind_collections.length-1;d++){
                 
      var docFound = parseInt(myFind_collections[d]);
                 
      if(pgMatch===docFound){
                          myFind_collections
      .splice(myFind_collections[d],1);
                          alert
      (docFound + " was removed");
                     
      }
                 
      }
         
      }

      alert
      (myFind_collections.length);

       

      in above code i want to remove every item in myFind_collections which equals to pgRangeCollection

      i want the output as (3,6,10) but i am getting the output as (248,249,250)

      i dont know where i mistaking can anybody suggest solution for this,

      Thanks in advance