I have a set of variables declared that has a structure, that is NameOfVar_NumberOfVar. Now I will be assigning equal values to all the declared variables. How do I add to create a loop to make the following assignment shorter?
I know the best way would be to declare an array, but I am continuing a code where arrays have not been used rather the following example has been used. So in such a case, I am trying to look for an optimized approach.
<script>
var ab_01;
var ab_02;
var ab_03;
var ab_04;
//tedious process
ab_01 = 10;
ab_02 = 10;
ab_03 = 10;
ab_04 = 10;
//optimized process?
for(var i = 0; i < 4; i++)
{
//Assign [i] to the declared var
}
</script>