I have come up with the following solution for calling different functions based on an argument value. Is there a better/simpler way?
function mainFunction(input, category) {
categories = {
'category1': () => { return { /* return stuff */ }}
'category2': () => { return { /* return stuff */ }}
}
return categories[category].call();
}
Thank you!
category1andcategory2are insidemainFunction, other than to call them based on those string values? Would it make sense in the context of your program if those functions were defined outside ofmainFunction?