I have three enums
Country_INDIA, Country_USA,Country_AUSTRALIA
. During runtime, the specific country name
is determined (it could be either INDIA, USA, or AUSTRALIA). Is it possible to select the correct enum based on the country name at runtime? For instance, if the country name is USA
, I need to choose the Country_USA enum.
enum Country_INDIA {
INTREST_RATE = '10%',
MIN_INVESTMENT_DURATION = "5YRS"
};
enum Country_USA {
INTREST_RATE = '3%',
MIN_INVESTMENT_DURATION = "3YRS"
};
enum Country_AUSTRALIA {
INTREST_RATE = '5%',
MIN_INVESTMENT_DURATION = "2YRS"
};
let country_enum = "Country_"+"USA"
console.log(country_enum.INTREST_RATE); // Retrieve the interest rate from the 'Country_USA' enum