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 4ed4f8c commit 051948cCopy full SHA for 051948c
Week2/prep-exercises/1-traffic-light/traffic-light.js
@@ -7,12 +7,18 @@
7
8
function getCurrentState(trafficLight) {
9
// TODO
10
+ return trafficLight.possibleStates[trafficLight.stateIndex];
11
// Should return the current state (i.e. colour) of the `trafficLight`
12
// object passed as a parameter.
13
}
14
15
function getNextStateIndex(trafficLight) {
16
17
+ if(trafficLight.stateIndex == 2){
18
+ return 0;
19
+ }else{
20
+ return (trafficLight.stateIndex = trafficLight.stateIndex + 1);
21
+ }
22
// Return the index of the next state of the `trafficLight` such that:
23
// - if the color is green, it will turn to orange
24
// - if the color is orange, it will turn to red
0 commit comments