title: Use multiple key-value filters on an object of objects?
body: <p>Bit of a lengthy one so those of you who like a challenge (or I'm simply not knowledgeable enough - hopefully it's an easy solution!) read on!</p>
  <p>(skip to the actual question part to skip the explanation and what I've tried)</p>
  <p><strong>Problem</strong></p>
  <p>I have a site that has a dataset that contains an object with multiple objects inside. Each of those objects contains an array, and within that array there are multiple objects. (yes this is painful but its from an API and I need to use this dataset without changing or modifying it.) I am trying to filter the dataset based of the key-value pairs in the final object. However, I have multiple filters being executed at once.</p>
  <p>Example of Path before looping which retrieves the key-value pair needed for one hall.</p>
  <pre><code>[&quot;Hamilton Hall&quot;][&quot;Hire Options&quot;][2].Commercial
  </code></pre>
  <p>After Looping Path of required key-value pair for all halls, not just one (the hall identifier is stored):</p>
  <pre><code>[0][&quot;Hire Options&quot;][2].Commercial
  </code></pre>
  <p>Looping allows me to check each hall for a specific key-value pair (kind of like map or forEach, but for an object).</p>
  <p>After getting that out of the way back to the question.</p>
  <p>How would I go about filtering which of the looped objects are displayed?</p>
  <p><strong>What I have Tried</strong></p>
  <p>(userInput is defined elsewhere - this happens on a btn click btw)</p>
  <pre><code>    let results = Object.keys(halls);
      for (key of results) {
          let weekend = [halls[ `${key}` ][ 'Hire Options' ][4][ 'Weekend function' ]];
          if(userInput == weekend) {
              outputAll([halls[ `${key}` ]]);
          }
      }
  </code></pre>
  <p>That filters it fine. However, I run into an issue here. I want to filter by multiple queries, and naturally adding an AND into the if statement doesn't work. I also dont want to have 10 if statements (I have 10+ filters of various data types I need to sort by).</p>
  <p>I have recently heard of ternary operators, but do not know enough about them to know if that is the correct thing to do? If so, how? Also had a brief loook at switches, but doesnt seem to look like what I want (correct me if I am wrong.)</p>
  <p><strong>Actual Question minus the babble/explanation</strong></p>
  <p>Is there a way for me to dynamically modify an if statements conditions? Such as adding or removing conditions of an if statement? Such as if the filter for 'a' is set to off, remove the AND condition for 'a' in the if statement? This would mean that the results would only filter with the active filters.</p>
  <p>Any help, comments or 'why haven't you tried this' remark are greatly appreciated!</p>
  <p>Thanks!</p>
  <p>Just for extra reference, here is the code for retrieving each of the objects from the first object as it loops through them:</p>
  <p>(Looping Code)</p>
  <pre><code>        halls = data[ 'Halls' ];
          let results = Object.keys(halls);
          for (key of results) {
              let arr = [halls[ `${key}` ]];
              outputAll(arr);
          }
  </code></pre>