Skip to content

Commit 168bcb3

Browse files
Merge pull request #1 from amaniomaisy90/pre-exercise-js-week1
Updated traffic light-1 exercise
2 parents c4a01c2 + ab7db6b commit 168bcb3

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.DS_Store

0 Bytes
Binary file not shown.

Week1/.DS_Store

6 KB
Binary file not shown.

Week1/prep-exercises/.DS_Store

6 KB
Binary file not shown.

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@ while (rotations < 2) {
1212
const currentState = trafficLight.state;
1313
console.log("The traffic light is on", currentState);
1414

15-
// TODO
16-
// if the color is green, turn it orange
17-
// if the color is orange, turn it red
18-
// if the color is red, add 1 to rotations and turn it green
15+
if (currentState === "green") {
16+
trafficLight.state = "orange" ;
17+
18+
}else if (currentState=== "orange") {
19+
trafficLight.state= "red";
20+
} else if (currentState === "red") {
21+
rotations++;
22+
trafficLight.state= "green" ;
23+
}
1924
}
2025

2126
/**

0 commit comments

Comments
 (0)