added iterating condition for for loop
added assigning variable

but test the code
read some loop jsperf test
consolidated looping references