Some really simple code?

for (var i = 0;i<9;i++) {
trace(“Starting Loop”);
a += i;
trace(“ending loop”);

Ok I understand how i is being assigned but when I trace(a) after the 2nd loop it traces the number 3 and from there a is changed HOW exactly is it doing that? I dont understand!
This is some code i was looking up in a book and i’m frustrated because I dont understand how the variable a is changing! :q: :q:

Your “a” variable is += the i

There for you have 9 loops and all the while i is increasing by 1

i = 0,1,2,3,4,5,6,7,8

(0+1=1, 1+1=2, 2+1=3, etc)

a = 0,1,3,6,10,15,21,28,36

(0+0=0, 0+1=1, 1+2=3, 3+3=6, 6+4=10, 10+5=15, etc)