Skip to content

Challenge # 3 solution

raulco1 edited this page May 29, 2020 · 1 revision

This is my initial solution up to challenge 3. it seems to work well confused about elevator.goToFloor(0,true); I am trying to understand this before i move on.

{

    init: function(elevators, floors) {
        var elevator = elevators[0]; // Let's use the first elevator
        // Whenever the elevator is idle (has no more queued destinations) ...
        elevator.on("idle", function() {
            // let's go to all the floors (or did we forget one?)
            elevator.goToFloor(0,true);
            elevator.goToFloor(1);
            elevator.goToFloor(2);
            elevator.goToFloor(3);
            elevator.goToFloor(4);
        });
    },
    update: function(dt, elevators, floors) {
        // We normally don't need to do anything here
    }

}

Clone this wiki locally