We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a2526f commit 0115324Copy full SHA for 0115324
1 file changed
Week2/prep-exercises/1-traffic-light/traffic-light.js
@@ -6,9 +6,11 @@
6
*/
7
8
function getCurrentState(trafficLight) {
9
+
10
// TODO
11
// Should return the current state (i.e. colour) of the `trafficLight`
12
// object passed as a parameter.
13
+ return trafficLight.possibleStates[trafficLight.stateIndex];
14
}
15
16
function getNextStateIndex(trafficLight) {
@@ -17,6 +19,7 @@ function getNextStateIndex(trafficLight) {
17
19
// - if the color is green, it will turn to orange
18
20
// - if the color is orange, it will turn to red
21
// - if the color is red, it will turn to green
22
+ return (trafficLight.stateIndex + 1) % trafficLight.possibleStates.length;
23
24
25
// This function loops for the number of seconds specified by the `secs`
0 commit comments