title: jQuery filter with checkboxes
body: <p>I have a grid which I need to filter by 2 different properties. Location &amp; Language.</p>
  <p>I've created an array of checked elements for each property and need to be able to filter the results by these.</p>
  <p><a href="https://codepen.io/lee-grant/pen/bGWzRYJ?editors=1111" rel="nofollow noreferrer">https://codepen.io/lee-grant/pen/bGWzRYJ?editors=1111</a></p>
  <pre><code>  var filterActive;
  
      function filterCategory(cat1, cat2) {
          // Create an Array.
          var location = new Array();
  
          $('.location input[type=checkbox]:checked').each(function () {
              location.push(this.value);
          });
  
          if (location.length &gt; 0) {
              console.log('Location values: ', location);
          }
  
          // Create an Array.
          var language = new Array();
  
          $('.language input[type=checkbox]:checked').each(function () {
              language.push(this.value);
          });
  
          if (language.length &gt; 0) {
              console.log('Language values: ', language);
          }
  
          // reset results list
          $('.team-member').removeClass('active');
  
          // the filtering in action for all criteria
          var selector = '.team-member';
          if ($('.location input').is(':checked')) {
              selector = '[data-location*=&quot;' + location + '&quot;]';
          }
          if ($('.language input').is(':checked')) {
              selector = selector + '[data-language*=&quot;' + language + '&quot;]';
          }
  
          //show all results
          $(selector).addClass('active');
      }
  
      // start by showing all items
      $('.team-member').addClass('active');
  
      // call the filtering function when selects are changed
      $('.test :checkbox').change(function () {
          filterCategory(
              $('.location :checkbox:checked').val(),
              $('.language :checkbox:checked').val()
          );
      });
  </code></pre>
  <p>In the example it only works for 1 Location and 1 Language at a time; could anybody advise on how to get this to work correctly with multiple selections?</p>
  <p>Thank you</p>