I have an array of exceptions as shown below:
Exclusions: [ID:"233242", Loc:"West", ID:"322234" , Loc:"South"]
I am also an Object nested with an array of objects that might look something like
Schools : [ O: [ ID:"233242" ] , 1:[ ID:"233242"] , 2: [ID :"954944"] ]
I need to remove from school objects any corresponding array indices with the same identifier, but only for the first match . This means that element 0 should be deleted, but element 1 should still be there. What is the best way to fix my loop:
$.each(Exclusions, function (index, value) {
var loc = value.Loc;
var ID = value.ID;
Object.keys(Schools.District.Pack[loc]).forEach(function (key) {
if (Schools.District.Pack[loc].ID === ID) {
Schools.District.Pack[loc].splice(key, 1);
}
});
});
source
share