title: Iterating through an array inside a conditional && statement in javaScript?
body: <p>I have an array:</p>
  
  <pre><code>console.log(tenantArray)
  (8) ["WeWork", "Regus", "Spaces", "Knotel", "RocketSpace", "HQ Global Workspaces", "Other", "Select All"]
  </code></pre>
  
  <p>I also have a large data object, which I want to filter using d3, using a checkbox. The filter will be based on two conditions, the "Agency_Bro" property, and whether or not the "Tenant" property matches any of the strings in the tenantArray listed above.  In this sense, the "tenantArray" array above is just a dummy used for string matching purposes. Both conditions have to be true for filter.</p>
  
  <p>The filter works fine if it just reads:</p>
  
  <pre><code>d3.selectAll("#JLLCheckbox").on("change", function() {
  
              var type = "JLL"            
              display = this.checked ? "inline" : "none";
              d3.selectAll(".features")
              .filter(function(d) { 
                  return d.properties.Agency_Bro === type             
              })
              .attr("display", display);
  });
  </code></pre>
  
  <p>However, when I try to add in both conditional statements, the checkbox stops working (no data filtered) yet no error message occurs.</p>
  
  <pre><code>d3.selectAll("#JLLCheckbox").on("change", function() {
  
      var type = "JLL"            
      display = this.checked ? "inline" : "none";
  
      d3.selectAll(".features")
          .filter(function(d) { 
              return d.properties.Agency_Bro === type &amp;&amp;
                      tenantArray.forEach(function(entry) {
                      if (d.properties.Tenant === entry){
                          return d.properties.Tenant
                      }
                      });         
          })
  });
  </code></pre>
  
  <p>Two questions:  any reason the above logic is failing?  And, is there a more efficient way to do this, without going through the trouble of the array?  Thanks in advance!</p>