string as variable name in javascript -


i have array of objects: recs6, recs7, recs8...... recs23. want add factor in array using inner for loop. 'recs+n' interpreted string , not variable name. how can make represent existing variables - rec6, rec7 etc?

for(var n=6; n<24; n++){      for(var m=0; m<'recs+n'.length; m++){         hourbusyness += parsefloat(('recs'+n)[m].gtse);     }      houravgbusyness = hourbusyness / ('recs'+n).length;     console.log(houravgbusyness); } 

use this['recs'+n] instead of ('recs'+n)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -