JSON A ['711','722','733','744']
JSON B [{pid: 711, name: 'hello'},{pid: 733, name: 'world'}, {pid: 713, name: 'hello'},{pid: 744, name: 'hellosdaf'}]
I am attempting to remove elements from array B that match the values in JSON A. For example, if JSON B contains elements with PID 711, 733, and 744 which are also present in JSON A, I want to delete them.
I have tried using the function below but it is not working as expected, sometimes missing one or two strings during deletion:
angular.forEach(B, function(value, index){
if(A.indexOf(value.pid) > -1){
B.splice(index , 1);
}
});