A friend referred me to a job, but I already found a job and recently moved, so I wasn’t keen on interviewing. However, it wouldn’t be good to reschedule and then cancel directly. The position I applied for is in the web team, but unexpectedly, they immediately required a JavaScript test. While I’m decent with JavaScript, I’ve been focused on Python for the past few months, so I’ve somewhat forgotten how to write JavaScript code.
The task involves a task list where each task has setTimeout, callback, and dependency. The challenge is to write a runTask function to print them as required.
The solution seems to involve determining the tasks each task relies on, updating the completion status of each task after processing, and then checking if all dependencies for their dependents have been executed. This approach feels a bit cumbersome, so I’m wondering if there is a better solution. Any suggestions would be appreciated.