# Variable in a variable name

**URL:** https://forum.kirupa.com/t/variable-in-a-variable-name/324937
**Category:** flash
**Created:** [September 16, 2011, 6:50pm UTC](https://forum.kirupa.com/t/variable-in-a-variable-name/324937 "2011-09-16T18:50:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sogj](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sogj/32/3189_2.png) [@sogj](https://forum.kirupa.com/u/sogj)
#### Post date: [September 16, 2011, 6:50pm UTC](https://forum.kirupa.com/t/variable-in-a-variable-name/324937/1 "2011-09-16T18:50:01Z")

</div>

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?
