2022-01-21 18:38:22 +01:00
|
|
|
// eslint-disable-next-line
|
2022-01-21 15:41:53 +01:00
|
|
|
const breweries = data
|
|
|
|
const totals = {}
|
|
|
|
|
|
|
|
for (let brewery of breweries)
|
|
|
|
{const state = brewery.state
|
|
|
|
if (totals[state] == null)
|
|
|
|
{totals[state] = 1
|
|
|
|
} else
|
|
|
|
{totals[state]++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const entries = Object.entries(totals)
|
|
|
|
return entries.map(([state, count]) => ({ state, count }))
|