From 07a6ea67fc52abca1921a0100fc0112c49e2cdb1 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 29 Aug 2023 18:51:18 +0200 Subject: [PATCH] challenge1 completed --- challenge1.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 challenge1.md diff --git a/challenge1.md b/challenge1.md new file mode 100644 index 0000000..d851cb9 --- /dev/null +++ b/challenge1.md @@ -0,0 +1,30 @@ +Just direct the elevator where people are + +``` +{ + init: function(elevators, floors) { + var elevator = elevators[0]; + + elevator.on("idle", function() { + // idle in the middle for the shortest way + elevator.goToFloor(1); + }); + elevator.on("floor_button_pressed", function(floorNum) { elevator.goToFloor(floorNum);} ); + for(const floor of floors){ + floor.on("up_button_pressed", + function() { + elevator.goToFloor(floor.level); + }) + floor.on("down_button_pressed", + function() { + elevator.goToFloor(floor.level); + }) + } + + + }, + update: function(dt, elevators, floors) { + // We normally don't need to do anything here + } +} +``` \ No newline at end of file