If statement for onPress of multiple buttons
Hey all,
I have a list of 8 buttons. I want each button to call a function, which has already been created and pass some arguments.
So I have something like this:
test = function(btnX, btnY){
myOtherFunction(btnX);
anotherFunction(btnY);
};
but1.onPress = function(){
test(1,2);
};
but2.onPress = function(){
test(2,2);
};
but3.onPress = function(){
test(3,2);
};
but4.onPress = function(){
test(4,2);
}
Is there a way to create a switch or something else that is cleaner than making repeated .onPress functions for each button?
Thanks.