Skip to content

Instantly share code, notes, and snippets.

@typhoon2099
typhoon2099 / elevator.js
Last active April 14, 2025 11:53
Elevator Saga
{
init: function(elevators, floors) {
console.log("START");
const upIndicators = new Set();
const downIndicators = new Set();
// TODO: Let the floor button presses control the elevator queues (big rewrite)
const TOP_FLOOR_NUM = floors.length - 1;
const goingUp = floors => floors.filter(floor => floor.buttonStates.up === "activated");
const goingDown = floors => floors.filter(floor => floor.buttonStates.down === "activated");