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


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

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