Have a problem that I feel like must have been solved in some elegant ways but wanting some input. I\'m using vanilla Javascript to solve this but wondering if perhaps there is