title: JavaScript array.filter() and iterator
body: <p>got a array of objects and need to filter this by 2 criterias. One of those criterias is an index counting up. </p>
  
  <pre><code>let data = 
  [{"hour": 1, "dayIndex": 0, "value": "something"},
  {"hour": 1, "dayIndex": 1, "value": "something"},
  {"hour": 1, "dayIndex": 3, "value": "something"},
  {"hour": 2, "dayIndex": 0, "value": "something"},
  {"hour": 2, "dayIndex": 1, "value": "something"},
  // and so on 
  ]
  </code></pre>
  
  <p>I need an array of objects filtered by "hour" and ascending "dayIndex" and it is important that for missing dayIndexes an empty object is created. So for hour=1 I would need this: </p>
  
  <pre><code> let hourOneArray = 
   [
    {"hour" : 1, "dayIndex": 0, "value": "something"},
    {"hour" : 1, "dayIndex": 1, "value": "something"},
    {}, //empty because dayIndex 2 is missing
    {"hour" : 1, "dayIndex": 3, "value": "something"},
    {}, //empty because dayIndex 4 is missing
   ]
  </code></pre>
  
  <p>My approach was:</p>
  
  <pre><code>   for(let i = 0; i &lt; 4; ++i){
         hourOneArray = data.filter((arg) =&gt; {
             return ((arg.hour === 1) &amp;&amp; (arg.dayIndex === i));
         })
     } 
  </code></pre>
  
  <p>Thanks in advance </p>