fineanmol/Hacktoberfest2024

Write API for transform and sort json object grouped by city name

Rohitsonvane88 opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
const input = [
{
zip: '501',
city: 'Holtsville',
state_id: 'NY',
state_name: 'New York',
county_name: 'Suffolk'
},
{
zip: '544',
city: 'Holtsville',
state_id: 'NY',
state_name: 'New York',
county_name: 'Suffolk'
},
{
zip: '601',
city: 'Adjuntas',
state_id: 'PR',
state_name: 'Puerto Rico',
county_name: 'Adjuntas'
},
{
zip: '602',
city: 'Aguada',
state_id: 'PR',
state_name: 'Puerto Rico',
county_name: 'Aguada'
},
]

Describe the solution you'd like
const output = {
"Suffolk, New York (county)": {
"type": "county",
"zipcode": [
"00501",
"00544",
"06390",
"11701",
"11702",
"11703",
"11704",
"11705",
"11706"
]
},
"New York (state)": {
"type": "state",
"zipcode": [
"00501",
"00544",
"06390",
"10001",
"10002",
"10003",
"10004",
"10005",
"10006",
]
}
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

I am working on this issue, please assign it to me.