I have created the following:
var some_string = 'cb';
var a = 1;
var b = 2;
var c = 4;
var d = 8;
var mask = 0;
I want to store the a+b+c+d vars in the mask which works when I do:
mask |= c; // mask now equals 4
The problem I have is that I need to add the var value from within a loop:
mask |= some_string[0]
This doesn't work. I assume I have to convert some_string[0] because some_string[0]!=var c
EDIT: using eval works...
mask |= eval(some_string[0])
...considering eval gets such a bad rap, is there another way?