Consider a 4-lane traffic junction, controlled by one set of traffic lights which are located at position 50. When a vehicle reaches the same position as the traffic lights, it must obey the state of the lights. If the lights are red, the vehicle cannot move forward. If the lights are green, the vehicle can move forward. The traffic lights change every 10 seconds.
All traffic is moving in the same direction. When traveling, all vehicles move at the same, constant speed, of one vehicle length per second. Initial vehicle positions are 0, 12, 20, 24 The simulation runs until all vehicles pass through the traffic lights.
- written using pure JavaScript
- function as expected without any defects
- make good use of OO design principles
- represent the type of code that you would produce
node app