Trying to add different background colors to divs using a for loop. I stored all the colors in 20 variables and I want each of the 20 divs to have their own color. I'm trying to set it like this "background-color":(bar+i), but that does that work. It works if I just pass one variable like bar1. What am I doing wrong? Any help is greatly appreciated.
var bar1 = "#afb626";
var bar2 = "#5b590a";
var bar3 = "#b44708";
var bar4 = "#950000";
var bar5 = "#eb9f9f";
var bar6 = "#246d13";
var bar7 = "#afb626";
var bar8 = "#a60046";
var bar9 = "#733702";
var bar10 = "#d1570d";
var bar11 = "#afb626";
var bar12 = "#5b590a";
var bar13 = "#b44708";
var bar14 = "#950000";
var bar15 = "#eb9f9f";
var bar16 = "#246d13";
var bar17 = "#afb626";
var bar18 = "#a60046";
var bar19 = "#733702";
var bar20 = "#afb626";
for (var i = 0; i < 20; i++) {
$('<div/>', { id: 'foo'+i,}).appendTo('body');
$("#foo"+i).css({"background-color":(bar+i),"height": "100%", "width": screenWidth, "float": "right"});
}