Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 746 Bytes

File metadata and controls

9 lines (6 loc) · 746 Bytes

Prep exercise - traffic light

Let's have a deeper look at the working of traffic lights this week so that we can practice logic and loops. In traffic-light-1.js and traffic-light-2.js you will find the same requirements but with different ways of representing the traffic light. Have a look through the files and solve them so you can see how the way we represent data affects the way we need to solve problems.

Things to think about

  • Which way of representing the traffic light did you find better? Why?
  • What happens if you change the loop to a do-while loop instead of a while loop? Why?
  • We could have also used a for loop to make the traffic light do 2 full rotations. Do you think that would be better? Why or why not?