title: Finding all object indices satisfying testing function, like array.findIndex() but more than first index
body: <p>I have an array of objects:</p>
  
  <pre><code>var data = [{"district":"201","date":"Wed Apr 01 2020","paper":671.24,"mgp":36.5},
  {"district":"202","date":"Wed Apr 01 2020","paper":421.89,"mgp":44.2},
  {"district":"203","date":"Wed Apr 01 2020","paper":607.85,"mgp":67.36},
  {"district":"201","date":"Sun Mar 01 2020","paper":571.24,"mgp":38.8},
  {"district":"202","date":"Sun Mar 01 2020","paper":421.89,"mgp":36.6},
  {"district":"203","date":"Sun Mar 01 2020","paper":607.85,"mgp":69.36},
  {"district":"201","date":"Sat Feb 01 2020","paper":571.24,"mgp":38.8},
  {"district":"202","date":"Sat Feb 01 2020","paper":421.89,"mgp":22.2},
  {"district":"203","date":"Sat Feb 01 2020","paper":607.85,"mgp":59.66},
  {"district":"201","date":"Wed Jan 01 2020","paper":571.24,"mgp":38.8},
  {"district":"202","date":"Wed Jan 01 2020","paper":421.89,"mgp":22.2},
  {"district":"203","date":"Wed Jan 01 2020","paper":607.85,"mgp":89.26}]
  </code></pre>
  
  <p>For each <code>district</code> I would like to take the values of <code>paper</code> and <code>mgp</code> for February, March, and April and divide each month's values by their January values to measure % change. </p>
  
  <p>Using Array.findIndex() and reduce() (like <a href="https://stackoverflow.com/questions/30667121/javascript-sum-multidimensional-array">here</a>) I can match the districts and return the correct value, but that only returns the first index of the match, and there are repeat indices because there are subsequent months. I've tried wrapping a loop of months around the findIndex() to no avail: <code>console.log(result)</code> returns nothing</p>
  
  <pre><code>var result = data.reduce((a, b) =&gt; {
               var months = [...new Set(a.map(m =&gt; a.date))];
               for (var month of months){
                var idx = a.findIndex(e =&gt; e.district == b.district &amp;&amp; e.date == month)
                if (~idx &amp;&amp; b.date === "Wed Jan 01 2020") {
                 a[idx].paper = a[idx].paper/b.paper;
                 a[idx].mgp = a[idx].mgp/b.mgp} 
                else {
                 a.push(JSON.parse(JSON.stringify(b)));
               }
               return a
               }, []);
  </code></pre>
  
  <p>Result should look like this:</p>
  
  <pre><code>[{"district":"201","date":"Wed Apr 01 2020","paper":1.17,"mgp":0.94},
   {"district":"202","date":"Wed Apr 01 2020","paper":1,"mgp":1.99},
   {"district":"203","date":"Wed Apr 01 2020","paper":1,"mgp":0.75},
   {"district":"201","date":"Sun Mar 01 2020","paper":1,"mgp":1},
   {"district":"202","date":"Sun Mar 01 2020","paper":1,"mgp":1.64},
   {"district":"203","date":"Sun Mar 01 2020","paper":1,"mgp":0.77},
   {"district":"201","date":"Sat Feb 01 2020","paper":1.17,"mgp":1},
   {"district":"202","date":"Sat Feb 01 2020","paper":1,"mgp":1},
   {"district":"203","date":"Sat Feb 01 2020","paper":1,"mgp":0.67]
  </code></pre>