JavaScript Iterating through an array inside a conditional && statement in javaScript? iterating through array javascript,iterating through array python,iterating through

I have an array:

console.log(tenantArray)
(8) ["WeWork", "Regus", "Spaces", "Knotel", "RocketSpace", "HQ Global Workspaces", "Other", "Select All"]

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.

The filter works fine if it just reads:

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);
});

However, when I try to add in both conditional statements, the checkbox stops working (no data filtered) yet no error message occurs.

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 &&
                    tenantArray.forEach(function(entry) {
                    if (d.properties.Tenant === entry){
                        return d.properties.Tenant
                    }
                    });         
        })
});

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!

Answer:1

I make one call that retrieves multiple GUIDs using the WebAPI. I loop through each result and update records accordingly. This is all being done asynchronously. I do not want the user to wait for all ...

I make one call that retrieves multiple GUIDs using the WebAPI. I loop through each result and update records accordingly. This is all being done asynchronously. I do not want the user to wait for all ...

I want to open a specific tab of bootstrap 4 from external page link . Page 1: nav.html I want to go from this page one to second page <!DOCTYPE html> <html> <head> <title&...

I want to open a specific tab of bootstrap 4 from external page link . Page 1: nav.html I want to go from this page one to second page <!DOCTYPE html> <html> <head> <title&...

When i run console.log (f ()) i want it returns the data that came from getData (url), but it keeps returning Promise {<pending>}. I thought using await keyword would solve this by making the ...

When i run console.log (f ()) i want it returns the data that came from getData (url), but it keeps returning Promise {<pending>}. I thought using await keyword would solve this by making the ...

Is it possible to mark (change color/size etc) vertex in editable Polygon? var polygon = new google.maps.Polygon({ map:_map, path:path, editable:true, ...

Is it possible to mark (change color/size etc) vertex in editable Polygon? var polygon = new google.maps.Polygon({ map:_map, path:path, editable:true, ...

  1. google maps polygon area
  2. google maps polygon tool
  3. google maps polygon label
  4. google maps polygon api
  5. google maps polygon edit event
  6. google maps polygon creator
  7. google maps polygon coordinates tool
  8. google maps polygon remove point
  9. google maps polygon z index
  10. google maps polygon fill pattern
  11. google maps polygon title
  12. google maps polygon click event
  13. google maps polygon center
  14. google maps polygon to geojson
  15. google maps polygon overlay
  16. google maps polygon infowindow
  17. google maps polygon drawing
  18. google maps polygon get coordinates
  19. google maps polygon get bounds
  20. google maps polygon with hole