Alternates between turning the color LEDs on and off.
Like led.toggle()
, colorLeds[i].toggle()
changes based on the current state of the LED, like a light switch.
This method can work as an alternative to colorLeds[i].on()
and colorLeds[i].off()
depending on the situation it's being used in.
onBoardEvent("buttonL", "press", function(event) { colorLeds[(randomNumber(7, 9))].toggle(); colorLeds[(randomNumber(4, 6))].toggle(); colorLeds[(randomNumber(0, 3))].toggle(); });
colorLeds[index].toggle()
Found a bug in the documentation? Let us know at documentation@code.org