Question: Ok, i cannot make this work so i'm turning to you, i've been hacking away at this all morning and i give up. I have some checkboxes which create an array of filters like this:

```
var filters = [Diesel,CarWash]

```

I'm trying to filter a JSON file to find a match that contains all (not any) the items in that filter set. So, for the array above, i'd like to filter the JSON file (sample below) to find a location with both Diesel AND CarWash. That would return only the last item, which has both. I'm using jquery for this project and I think that $filter will work but it is beyond my ken. 

```
[
  {
    "FacilityID": 123,
    "Diesel": 0,
    "ATM": 0,
    "CarWash": "None"
  },
{
    "FacilityID": 456,
    "Diesel": 1,
    "ATM": 0,
    "CarWash": "None"
  },
{
    "FacilityID": 789,
    "Diesel": 1,
    "ATM": 0,
    "CarWash": "Full"
  }
]

```

Answer: 
This would work: 

```js
var filters = {Diesel: "1", CarWash: "Full"};

    var facilities = [{
        "FacilityID": 123,
        "Diesel": 0,
        "ATM": 0,
        "CarWash": "None"
      },
      {
        "FacilityID": 456,
        "Diesel": 1,
        "ATM": 0,
        "CarWash": "None"
      },
      {
        "FacilityID": 789,
        "Diesel": 1,
        "ATM": 0,
        "CarWash": "Full"
      }
    ];

    var selectedFacility = null;

    // loop over each facilities
    $.each(facilities, function(i, facility) {
      var matchesAllFilters = true;
      // loop over each filter
      $.each(filters, function(filterName, filterValue) {
        var facilityValue = facility[filterName];

        if (filterValue != facilityValue) {
            matchesAllFilters = false;
          return false;
        }
      });
      if (matchesAllFilters) {
        selectedFacility = facility;
      }
    });

    console.log(selectedFacility );
```

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
```
Please try out this.

```
$(document).ready(function(){
  var data = [
    {
      "FacilityID": 123,
      "Diesel": 0,
      "ATM": 0,
      "CarWash": "None"
    },
    {
        "FacilityID": 456,
        "Diesel": 1,
        "ATM": 0,
        "CarWash": "None"
      },
    {
        "FacilityID": 789,
        "Diesel": 1,
        "ATM": 0,
        "CarWash": "Full"
      }
    ]

    returned_value = retun_value(data)
    alert(returned_value)
});

function retun_value(data){
    for(i=0; i<data.length; i++ ){
       if(data[i].Diesel && data[i].CarWash && data[i].CarWash !='None'){
         return i
       }
    }
}

```