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 30024ba commit ec47026Copy full SHA for ec47026
Week1/prep-exercises/1-traffic-light/traffic-light-1.js
@@ -3,15 +3,22 @@
3
* The `state` property says what the traffic light's state (i.e. colour) is at
4
* that moment.
5
*/
6
-const trafficLight = {
+let trafficLight = {
7
state: "green",
8
};
9
10
let rotations = 0;
11
while (rotations < 2) {
12
const currentState = trafficLight.state;
13
console.log("The traffic light is on", currentState);
14
-
+if(currentState == "green"){
15
+ trafficLight.state = "orange";
16
+} else if(currentState == "orange"){
17
+ trafficLight.state = "red";
18
+}else{
19
+ rotations++;
20
+ trafficLight.state = "green";
21
+}
22
// TODO
23
// if the color is green, turn it orange
24
// if the color is orange, turn it red
0 commit comments