I have an object with about 30 'values' or whatever they are called, for example:
var list = new Object();
list.one = 0;
list.two = 0;
list.three = 0;
...
list.thirty = 0;
is there a simple/efficient way for me to be able to increment the values of the list object?
For example let's say there are 100 buttons, each button if pressed will increase the value by a certain amount. What I'm trying to do is a short function like:
function test( value, amount, math ) {
if( math === "add" ) {
value += amount;
} else if( math === "sub" ) {
value -= amount;
}
}
but the whole value thing doesnt work =(. The only other way I can think about doing it is creating 30 functions, each function to do the same thing as above but each one specifies the list value to add or subtract to. or make a single function with if value === "one" then list.one etc. Any other ideas? I've thought about using an array but I'd prefer having the code be easy to read since the list values have specific names that make it easy for me in other functions.
Thanks in advance for any help