I've been struggling with a for loop issue. I would like to declare variables using a for loop, such that with each iteration of the for loop I have a new variable with an added index number as the end.
Here's an example of what I mean
for (var i = 1; i <= 8; i++) {
ingroupProfileText+i = console.log(i);
}
So, with each iteration, the loop is effectively doing the following:
ingroupProfileText1 = console.log(1);
ingroupProfileText2 = console.log(2);
ingroupProfileText3 = console.log(3);
ingroupProfileText4 = console.log(4);
ingroupProfileText5 = console.log(5);
ingroupProfileText6 = console.log(6);
ingroupProfileText7 = console.log(7);
ingroupProfileText8 = console.log(8);
I've looked around and I keep coming across suggestions where some suggest to use an array, eval, or window. I want something locally, and I haven't been able to make it work either way.
Any help would be much appreciated :)