Is there a way to keep my variables used in a for loop within a function scope instead of being global?
I attempted to enclose the for loop inside a function as shown below, but I encountered console errors:
function() {
var data = livingroomTableData;
for(var i = data[0]; i < data[1]; i++) {
var elemvalue = data[2] + format(i) + ".png";
livingroomTableArray[i] = elemvalue;
}
}
My goal is for the 'data' variable to only have access to the values of livingroomTableData within this specific for loop and not throughout the entire script. For other loops, I plan to assign a different variable to 'data'.
Just a heads up, I'm pretty new to all of this. :S