In my Javascript code, I work with two arrays named "array1" and "array2".
Initially, the currentArray is set to array1. However, when the user clicks on a certain button, the currentArray switches to array2, and then back to array1 if clicked again.
This approach allows me to easily access the arrays in my code using pseudocode like:
{currentArray}.getText;
{currentArray}.getText;
I am wondering if it is possible to implement this functionality. If so, how can I achieve it? I am aware that using if statements is one way, but I prefer having the simplicity of just modifying the currentArray variable without scattered if statements throughout the code.