A for loop beginner's question
In the following code :
var result = 1;
for (var counter = 0; counter < 10; counter = counter + 1)
result = result * 2;
I can't figure out what is the relationship between variables result and counter. It works, I know but I don't see how this is possible since there is no code assembling both variables together in a single operation.
Hope I am being clear enough.
There isn't a direct relationship between the variables 'result' and 'counter' in your script. They have separate purposes. The counter just keeps track of the number of times the loop is processed, and each time the loop is processed, 'result' is doubled.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)