Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 009bd90

Browse files
authored
Update traffic-light-1.js
1 parent 61e010f commit 009bd90

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Week1/prep-exercises/1-traffic-light/traffic-light-1.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ let rotations = 0;
1111
while (rotations < 2) {
1212
const currentState = trafficLight.state;
1313
console.log("The traffic light is on", currentState);
14+
15+
if (currentState === "green") {
16+
trafficLight.state = "orange";
17+
} else if (currentState === "orange") {
18+
trafficLight.state = "red";
19+
} else {
20+
trafficLight.state = "green";
21+
rotations++;
22+
}
23+
}
1424

1525
// TODO
1626
// if the color is green, turn it orange

0 commit comments

Comments
 (0)