Estoy buscando optimizar este código usando un bucle.
a = new Array("green","blue","pink","white"); b = new Object(); b.green = 21; b.blue = 22; b.pink = 23; b.white = 24; for(n=0; n<=3; n++){ // Code would look like below but a[n] would be the array name, ie b.red = (21+n) and loop through the other colours. ba[n] = (21+n); };En lugar de escribir código como el anterior, ¿es una forma de incluirlo en un bucle?