[Solved] how can I get a JSON like this with javascript [closed]

[ad_1]

Loop over the rows. Keep the province as key. Before adding do a check if the key is already present. If already present add to array.Something like this,

if(obj[key]){
  obj[key].push(city);
}else{
  obj[key] = [];
  obj[key].push(city);
}

3

[ad_2]

solved how can I get a JSON like this with javascript [closed]