I feel like this is such a simple question it’s surely been answered somewhere before, but I can’t find anything on google or the forum search that can help me.
I have several variables. To make it simple lets say they are named “VariableA” “VariableB” and “VariableC”.
They are each integers and I need to add 1 to each depending on what variable I am sent. So if I am sent, for instance, an “A” I need VariableA to increase by 1.
I’d really like to avoid a switch statement if possible.
I tried:
this[“Variable”+varLetter]++; //where varLetter is a string holding either “A” “B” or “C”
But that didn’t work.
Then I tried
this[“Variable”+String(varLetter)]++; //after finding a forum post on another forum that suggested this
But that didn’t work either.
I know I’m missing some fundamental concept I just can’t grasp! What’s the right syntax?