I have 10 variables. q1 through q10
my script is as follows:
if (q1 == '1') { q1 = 'Yes';
} else if (q1 == '2') { q1 = 'No';
} else { q1 = 'Did Not Answer'; }
I already typed this out for all 10. I am not sure if I can insert another variable into this variable.
I'm trying to do something like this:
var ex = '1';
while (ex < 11) {
if (q[ex] == '1') { q[ex] = 'Yes'; ex++;
} else if (q[ex] == '0') { q[ex] = 'No'; ex++;
} else { q[ex] = 'Did Not Answer'; ex++ }
Basically I want to eliminate 4 lines of code x 10 variables.
[ex] is a variable inside the variable (to represent q1, determine q1 = Yes, No, or Did Not Answer, then add 1 to q[ex] which would now be q2....
I understand that the [] may not be correct, I just don't know how to explain this in a way that is understandable.
Thank you.