image - Weird behaviour with for loop in JavaScript -


i have image table has 2 columns , 20 rows. when executing loop, rows working okay except first row, displays first image on left. it's weird; there wrong order of execution?

var image= []; var rows=5;         (var = 0; < test.length; i++) {     var avatar = test[i].image; // profile image      if(i % 2 === 0){         image[i]= titanium.ui.createimageview({             top:row,             image:avatar             align:right             });         win.add(image[i]);         //trying increase image         row =row+200;     } else if(i % 2 === 1) {         image[i]= titanium.ui.createimageview({             top:row,             image:avatar             align:left             });         win.add(image[i]);     } } 

i=0, i%2=0, show image (supposed right), row+=200;

i=1, i%2=1, show image (left side), row stays same

i=2, i%2=0, show image (right side), row+=200

0%2 = 0, , represents right side image, , goes next line. need play around increment row , side loop starts with.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -