JSFiddle - React, Tailwind, and code Playground
JavaScript
var object = {
flapWings : function(count) {
alert("I am flapping my wings "+count+" times");
},
kick : function(count) {
alert("I am kicking my legs "+count+" times");
},
functionmap : {
"bird" : {
label : "Bird",
action : function(param) {
object.flapWings(param);
}
},
"horse" : {
label : "Horse",
action : function(param) {
object.kick(param);
}
}
},
doAction : function (type, count) {
alert("I am a "+this.functionmap[type].label);
this.functionmap[type].action(count);
}
};
object.doAction("horse", 5);