Skip to content

Latest commit

 

History

History

1-traffic-light

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Prep exercise - Traffic light

In the previous week we continued with our traffic light. Now that we also know what a function is we have one last look at the workings of a traffic light in a different way. Take a look at the traffic-light.js file and implement the same requirements as last week again, but then with another different way of organising.

Things to think about

  • This time the loop was changed to a for loop that will run the code 6 times. Why was that needed?
  • Why was the trafficLight added to the main function and not left at the top of the file?
  • What do you think is the advantage of having the getCurrentTrafficLightState and getNextStateIndex functions?