Here, i am implementing an GeoMap asset which has all the countries. in this, all countries has their own class such as BTNMongolia, BTNHungary etc. i have only countries name to get object and based on countries name, i want to get object of the country's class. i'm doing like this.
function countryObject(country) {
switch (country) {
case 'mongolia':
return new BTNMongolia();
case 'mongolia':
return new BTNHungary();
case 'mongolia':
return new BTNComoros();
case 'mongolia':
return new BTNAntiguaandBarbuda();
case 'mongolia':
return new BTNSouthKorea();
case 'mongolia':
return new BTNAustralia();
case 'mongolia':
return new BTNTajikistan();
default:
return null;
}
}
here, to get object, i want to get object of the country'class from the country'name itself. is there is a short way to do that?.