I am working on creating an array for each user and storing them in another array. Here is the code snippet I used for this:
var arrays = [];
var userCounter = 1;
@foreach($eventUsers as $user)
{
arrays['arr' + userCounter] = [];
userCounter++;
}
When I console.log(arrays), it showed me the following output:
[arr1: Array[0], arr2: Array[0], arr3: Array[0], arr4: Array[0]]
Now, I need to add elements to each individual array (arr1, arr2, arr3, arr4) while looping through 'arrays'.
I attempted the following approach:
for (arrayName in arrays) {
arrayName.push('x');
}
Unfortunately, this didn't work as expected. Can anyone provide a solution?