The snake biting its own tail

Disclaimer: I’m a beginner at JS, so don’t ask me about the many intricacies of JS.

I’ve been working on a Shiny app for work these past few weeks, and had to use Javascript to solve a very specific issue I encountered. Something for which, as far as I know, there is no other solution than using Javascript. The problem …