function getGuangdongCity () {
  const guangdongCity = [
    {
      name: 'shenzhen',
      id: 11,
    }, {
      name: 'guangzhou',
      id: 12,
    }
  ];
  return guangdongCity;
};

function render (fn) {
  console.log('开始渲染广东省地图');
  document.write(JSON.stringify(fn()));
};

function addressAdapter (oldAddressfn) {
  let address = {},
    oldAddress = oldAddressfn();
  for (var i = 0, c; c = oldAddress[i++];) {
    address[c.name] = c.id;
  }
  return function () {
    return address;
  }
};
render(addressAdapter(getGuangdongCity));

Last Updated:
Contributors: pengrengui