title: how can I use map before reduce in an object of an array
body: <p>I want to sum each price with pervious value as a new array this is my object and my final array I
  except with my reducer I write</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>data=[{price: 2, volume: 123}
  {price: 3, volume: 123}
  {price: 4, volume: 254}
  {price: 1, volume: 444}
  {price: 5, volume: 555}]
  
  finaldata=[{price: 2, volume: 555}
  1: {price: 5, volume: 777}
  2: {price: 9, volume: 5000}
  3: {price: 10, volume: 8000}
  4: {price: 15, volume: 4000}]
  
   const test = buy.map((items, index) =&gt;
        items.reduce((prev, curr, currIndex) =&gt; {
          return index &gt;= currIndex ? { volume: (prev?.volume || 0) + curr?.volume } : 0;
        }, 0)
      );
      cons</code></pre>
  </div>
  </div>
  </p>