Elevator simulation in Javascript