I got data where in an array I got set of objects (with country and states keys along with values).
Now, I need to format data in such a manner, that I got a new array (with countryName as key, and list of states -in array as values).
I am trying to do that but unsuccessful. Can someone help me out?
var data = [
    {
        "country": "United States",
        "states": [
            "Alabama",
            "Alaska",
            "Arizona",
        ]
    },
    {
        "country": "Canada",
        "states": [
            "Ontario",
            "Saskatchewan",
            "Alberta",
        ]
    },
    {
        "country": "Australia",
        "states": [
            "Australian Capital Territory",
            "Jervis Bay Territory",
            "New South Wales",
            "Queensland",
        ]
    }
];
newData = []; 
data.map(item => newData.push({item.country: item.states});
console.log(newData); 
     
     
     
     
     
    