var color; switch (s){ case 0: color = "red"; break; case 1: color = "blue"; break; case 2: color = "green"; break; default: color = "black"; break; } label.style.color = color; ++s; if (4 <= s){ s = 0; } }, 1000);
for循环中: var speed = arrList1[i][j]; var col, r, g, b; if (speed > 2 && speed < 8) { col = speed - 3; r = 0; g = Math.round(col * 51); b = 255; } else if (speed >= 8 && speed < 13) { col = speed - 8; r = 0; g = 255; b = Math.round(255 - col * 51); } else if (speed >= 13 && speed < 18) { col = speed - 13; r = Math.round(col * 51); g = 255; b = 0; } else if (speed >= 18 && speed < 23) { col = speed - 18; r = 255; g = Math.round(255 - col * 51); b = 0; } else { r = 255; g = 0; b = 0; }