document.getElementById('AllButton').onclick = switchAll;
function illuminateRed() {
clearLights();
document.getElementById('stopLight').style.backgroundColor = "red";
}
function illuminateOrange() {
clearLights();
document.getElementById('slowLight').style.backgroundColor = "orange";
}
function illuminateGreen() {
clearLights();
document.getElementById('goLight').style.backgroundColor = "green";
}
function illuminateRedOrange() {
clearLights();
document.getElementById('stopLight').style.backgroundColor = "red";
document.getElementById('slowLight').style.backgroundColor = "orange";
}
function illuminateBlack() {
clearLights();
}
function clearLights() {
document.getElementById('stopLight').style.backgroundColor = "black";
document.getElementById('slowLight').style.backgroundColor = "black";
document.getElementById('goLight').style.backgroundColor = "black";
}
var clickTimes = 0;
var change = 1;
function switchAll() {
clickTimes++;
switch (clickTimes) {
case 1:
clearLights();
document.getElementById('stopLight').style.backgroundColor = "red";
break;
case 2: …Run Code Online (Sandbox Code Playgroud)