I have an array of Objects
: recs6
, recs7
, recs8
...... recs23
. I want to add a factor in the array using the inner for
loop. But 'recs+n' is interpreted as string and not as variable name. How can I make it represent the 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);
}