[WARNING! Proceed with caution]
One of my most recent coding dilemmas involves creating a JavaScript script that can identify specific surveys. These surveys use variables that share a common string followed by a random number, like this:
variableName_465;
variableName_212;
variableName_123;
If all these variables are initially set to false, how can I change them all to true at once? I attempted a loop that logs global scope variables:
for ( var i in window )
{
console.log(i, typeof window[i], window[i]);
}
However, setting i = true;
within the loop does not actually modify the variable itself; it seems like a new one is being created instead.
I'm unsure if what I'm trying to achieve is even possible. Any assistance you can provide would be greatly appreciated. Thank you!