how generate variable , assign inside loop dynamically?
for example,,
var tempclosingbalance, k = 1; (var = 0; < customarray.length; i++) { tempclosingbalance = "closingbalancewithtype" + k; (var j = 0; j < output.length; j++) { output[j].tempclosingbalance = customarray[i][j].closingbalancewithtype; } k++; } here tempclosingbalance variable have closingbalancewithtype1 , assign value, same condition continued assign value in closingbalancewithtype2, closingbalancewithtype3, etc.
i think following work. direct . operator not work here.
use output[j]["closingbalancewithtype" + k].
var tempclosingbalance, k = 1; (var = 0; < customarray.length; i++) { tempclosingbalance = "closingbalancewithtype" + k; (var j = 0; j < output.length; j++) { output[j][tempclosingbalance] = customarray[i][j].closingbalancewithtype; } k++; }
Comments
Post a Comment