I have an object that contains things i'm looking for:
Exclusions
1: Object [ ID: "38433" , Location: "Central"] 2: Object [ ID: "43434" , Location: "West"]
and I have a Object called Schools that contains the set of all things:
I am using the Object.keys()
method to loop through the object, but I need to pass in what Location to search to search in say Central, or West,etc. If I try to do something like (Schools.District.location) I get an error. How do i pass in the correct argument to my object.keys
function?
part2: What is the correct way to remove an element from that array. So i would need to remove Location[15] if say the ID's match.
Code:
$.each(Exclusions , function (index, value) {
var location = value.Location; //gives me Central, West, East
var ID = value.ID;
Object.keys(Schools.District.{{pass in location}}).forEach(function (key) {
//each location is an array of schools so i need to scan each for the matching ID
for (var i=0; i < {{get length of location array}}.length; i++) {
if(location[i][ID] == ID)
{
location.slice(); //not sure about this
}
}
});