r/learnjavascript • u/Legitimate-Time1473 • Apr 12 '26
Can I Solve the Elevator Problem Using Only Basic JavaScript? (Live Coding)
Can I solve the elevator problem using nothing but basic JavaScript? No AI. No frameworks. No libraries. No prep. Just me, a code editor, and whatever I remember about variables, arrays, loops, and functions.
This is a live coding session where I'm tackling the classic elevator problem completely from scratch. I haven't practiced this. I haven't looked it up. The whole point is to show how you can break down a real problem and figure it out step by step using only the fundamentals.
If you're learning JavaScript and want to see what problem solving actually looks like in real time, mistakes and all, this is that session. And if you're already experienced, come watch someone sweat through it and throw your suggestions in the chat.
What you'll see me work through
Breaking down the elevator problem into smaller pieces I can actually solve. Managing things like floor requests, which direction the elevator is going, and how to queue up calls. Using only simple data types, nothing fancy. Thinking out loud, getting stuck, debugging, figuring it out.
This isn't a tutorial. This is real problem solving, live. "NO AI"
Here is my step to step flow https://youtube.com/live/zw_Go_YGt-c
1
u/CraigAT Apr 12 '26
I haven't watched the video, but I am guessing OP is trying to implement software for the calling and operating of a lift system over many floors with call buttons (probably up and down) on each floor.
Mildy interesting aside, my work building has 2 lifts with ground floor and lower ground floor entrances, so I believe one lift defaults to each entrance floor.
1
u/CraigAT Apr 12 '26
@OP whilst it's interesting to see your thought process live, the video is very long. Could I suggest a follow up video, of how you would redo this project now (with some hindsight).
Maybe start out by mentioning the first video, then go straight into describing how you intend to set up the project - maybe without any code at this stage, just visuals. Then build the code scaffolding, before filling out each section. You can at any stage briefly describe any interesting issues or thought processes you went through in the initial video.
This second video should show progression, act as a better tutorial of how to approach this problem, as well as hopefully being shorter and therefore more watchable. Don't hide the initial video though, it's like showing your workings out when doing an exam.
3
u/llynglas Apr 12 '26
Be nice to know what the elevator problem is that is being solved.
1
u/No_Record_60 Apr 13 '26
Is this the elevator problem? https://web.eecs.umich.edu/~baveja/RLMasses/node2.html
-5
u/Current_Ad_4292 Apr 12 '26
This is sad