Hacker News new | ask | show | jobs
by emiphil 1837 days ago
for (elevator ... Like that is making a new global variable called elevator which is getting overwritten on the next loop. You need to for(const elevator... (or let).

The other thread is the same answer but for a slightly different case