I am trying to create a bunch of variables like this:
function l(){ var a1 = 2, a2 = 4, a3 = 6, a4 = 8, . .
Don't do this. Do. Not. Do. This. Use an array.
Given the trouble you're having creating them programmatically, how do you think you'd refer to them programmatically?