Q:

Use of dynamically created variables

I have a button with a click event function as seen below. I want to be able to use different variables inside the function (nose2x, nose2y and so on), i.e the variable names are the same except for the numbers.
I've tried build the variables like:
'AvGen.nose' + noseNr + 'Size'

... but it doesn't work.
How could it be done?
    biggerNoseBtn.on('click', function() {

        if (AvGen.nose1Size <= 1.8) {
            AvGen.nose1x -= 3;
            AvGen.nose1y -= 3;

            AvGen.nose1Size = AvGen.nose1Size += 0.1;
            AvGen.nose1Size = Math.round(AvGen.nose1Size * 10) / 10;

            AvGen.nose1.transform('S' + AvGen.nose1Size + ', ' + AvGen.nose1Size + ', 0, 0, T' + AvGen.nose1x + ', ' + AvGen.nose1y);
        }
    });

A:

Assuming AvGen is an object, you can use array notation to access its members. Try using this format:
if (AvGen['nose' + noseNr + 'Size'] <= 1.8) {
    // other code...
}

