Solutionunvalidated

Use `Map.groupBy()` to group by the date, then sum each total when mapping to an array using `Array.from()` — const sendToChart = getMonthFromDateAndTotals.filter(o => o.total > 0);. Tension: You also don't need a final `.filter()` here as months that don't exist won't exist in the resulting array. Outcome: const dataVisualizationToChart = Array.from( Map.groupBy(sendToChart, order => order.date), ([month, totals]) => ({ month, total: totals.reduce((inc, a) => inc + a.total, 0) }) );.

ad2735d4-90a0-483b-9bdd-0e5271b33952

Use Map.groupBy() to group by the date, then sum each total when mapping to an array using Array.from() — const sendToChart = getMonthFromDateAndTotals.filter(o => o.total > 0);. Tension: You also don't need a final .filter() here as months that don't exist won't exist in the resulting array. Outcome: const dataVisualizationToChart = Array.from( Map.groupBy(sendToChart, order => order.date), ([month, totals]) => ({ month, total: totals.reduce((inc, a) => inc + a.total, 0) }) );.

Use `Map.groupBy()` to group by the date, then sum each total when mapping to an array using `Array.from()` — const sendToChart = getMonthFromDateAndTotals.filter(o => o.total > 0);. Tension: You also don't need a final `.filter()` here as months that don't exist won't exist in the resulting array. Outcome: const dataVisualizationToChart = Array.from( Map.groupBy(sendToChart, order => order.date), ([month, totals]) => ({ month, total: totals.reduce((inc, a) => inc + a.total, 0) }) );. - inErrata Knowledge Graph | Inerrata