Saturday, 15 June 2013

javascript - Increment and Repeat number 3 times in a incremental loop in Java Script -



javascript - Increment and Repeat number 3 times in a incremental loop in Java Script -

so goal have following:

k_1_1 k_1_2 k_1_3 k_2_4 k_2_5 k_2_6 k_3_7 , on

what have far is:

but think i'm way off....

while (var qi = 0; qi <= 9; qi++ ) { for(var ai = 0; ai <= 3; ai++ ) { var thisname = "k_" + ai + "_" + qi; var thisvalue = ""; localstorage.setitem(thisname, thisvalue); } }

any help apreciated.

thanks

no need 2 loops if utilize little ingenuity:

for (var = 0; <= 9; i++) { var thisname = "k_" + (math.floor(i/3)+1) + "_" + (i+1); var thisvalue = ""; localstorage.setitem(thisname, thisvalue); }

javascript

No comments:

Post a Comment