2021-11-18 14:47:41 +01:00
|
|
|
const breweries = data
|
|
|
|
const totals = {}
|
|
|
|
|
2022-01-18 17:02:42 +01:00
|
|
|
for (let brewery of breweries)
|
|
|
|
{const state = brewery.state
|
|
|
|
if (totals[state] == null)
|
|
|
|
{totals[state] = 1
|
|
|
|
} else
|
|
|
|
{totals[state]++
|
2021-12-24 11:38:03 +01:00
|
|
|
}
|
|
|
|
}
|
2021-11-18 14:47:41 +01:00
|
|
|
const entries = Object.entries(totals)
|
2021-12-24 11:38:03 +01:00
|
|
|
return entries.map(([state, count]) => ({ state, count }))
|