title: Mapbox GL JS: build match expression based on multidimensional array
body: <p>I have the following array:</p>
  
  <pre><code>var SplitUpLevels = [
   [ zoomLevel: 6, locationIDs: [1, 2, 3]],
   [ zoomLevel: 10, locationIDs: [4, 5, 6]],
  ];
  </code></pre>
  
  <p>I want to hide some icons on the map, based on an individual zoomlevel and only if the location ID is in the array. I get the values dynamically from a JSON source.</p>
  
  <p>I already tried a simple forEach loop without any success:</p>
  
  <pre><code>"icon-opacity" : [
     "interpolate",
     ["linear"],
     ["zoom"],
     0,
     1,
  
     SplitUpLevels.forEach(function(SplitUpLevel) {
  
       SplitUpLevel.zoomlevel,
       [ "match", ["get", "Id"], SplitUpLevel.locationIDs, 0, 0 ] 
  
     }),
  
   … ]
  </code></pre>
  
  <p>I either get the response </p>
  
  <blockquote>
    <p>"icon-opacity: Expected an even number of arguments."</p>
  </blockquote>
  
  <p>or </p>
  
  <blockquote>
    <p>"icon-opacity[5]: Input/output pairs for "interpolate" expressions
    must be defined using literal numeric values (not computed
    expressions) for the input values."</p>
  </blockquote>
  
  <p>What's the best way to build such an expression, based on a dynamic source.</p>