I\'ve been trying to convert some messy code I inherited which is in JQuery 3.2 to vanilla Javascript to get rid of a few redundant dependencies from the site. One function