function buildHierarchy(data) {
  return data.reduce((hier, cls) => {
    if (!hier.hasOwnProperty(cls.region)) {
      hier[cls.region] = {};
    }
    if (!hier[cls.region].hasOwnProperty(cls.country)) {
      hier[cls.region][cls.country] = {};
    }
    if (!hier[cls.region][cls.country].hasOwnProperty(cls.city)) {
      hier[cls.region][cls.country][cls.city] = {};
    }
    return hier;
  }, {});
}
/*
 Builds an tree of the cities in countries and countries in regions for the
 filtering menus. Keys are the names
 */
Builds an tree of the cities in countries and countries in regions for the
filtering menus. Keys are the names
Builds an tree of the cities in countries and countries in regions for the filtering menus . Keys are the names
function buildHierarchy(data) {
  return data.reduce((hier, cls) => {
    if (!hier.hasOwnProperty(cls.region)) {
      hier[cls.region] = {};
    }
    if (!hier[cls.region].hasOwnProperty(cls.country)) {
      hier[cls.region][cls.country] = {};
    }
    if (!hier[cls.region][cls.country].hasOwnProperty(cls.city)) {
      hier[cls.region][cls.country][cls.city] = {};
    }
    return hier;
  }, {});
}
function buildHierarchy ( data ) { return data . reduce ( ( hier , cls ) => { if ( ! hier . hasOwnProperty ( cls . region ) ) { hier [ cls . region ] = { } ; } if ( ! hier [ cls . region ] . hasOwnProperty ( cls . country ) ) { hier [ cls . region ] [ cls . country ] = { } ; } if ( ! hier [ cls . region ] [ cls . country ] . hasOwnProperty ( cls . city ) ) { hier [ cls . region ] [ cls . country ] [ cls . city ] = { } ; } return hier ; } , { } ) ; }
Builds an tree of the cities in countries and countries in regions for the
filtering menus.
Builds an tree of the cities in countries and countries in regions for the filtering menus .