Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 009bd90 commit 2beedf4Copy full SHA for 2beedf4
Week1/prep-exercises/1-traffic-light/traffic-light-2.js
@@ -13,6 +13,16 @@ let cycle = 0;
13
while (cycle < 2) {
14
const currentState = trafficLight.possibleStates[trafficLight.stateIndex];
15
console.log("The traffic light is on", currentState);
16
+
17
+ if (currentState === "green") {
18
+ trafficLight.stateIndex = 1; // Turn it orange
19
+ } else if (currentState === "orange") {
20
+ trafficLight.stateIndex = 2; // Turn it red
21
+ } else if (currentState === "red") {
22
+ cycle++; // Increment cycles
23
+ trafficLight.stateIndex = 0; // Turn it green
24
+ }
25
+}
26
27
// TODO
28
// if the color is green, turn it orange
0 commit comments