I am trying to create a function that is called by multiple different buttons, and that selects a specific array depending on which button called the function.
For example:
If a button with id="Anterior" called the function, the function selects array named plusAnterior:
var plusAnterior = ["p", "b", "t", "d", "ɸ", "β", "f", "v", "θ", "ð", "s", "z", "m", "n", "l", "ɬ", "r", "ɾ"];
var minusAnterior = ["c", "ɟ", "k", "g", "ʃ", "ʒ", "x", "ɣ", "ɲ", "ŋ", "j", "w", "ʡ", "h"];
var toAdd = [];
function addFeature(featureId) {
if (activeFeatures === 0) {
toAdd = // plusAnterior called here
}
}
The problem is, I cannot simply do toAdd = plusAnterior because I want my function to work for any button pressed. I thought of doing something like getElementById("plus" + featureId), but I can't since the arrays I'm trying to select are not in my HTML.
Thank you for any help.