Oh okay. That’s odd. I couldn’t get it to work. I’ll have another look.
Alternatively, there are three other solutions that could work.
1. I could define the global variables at the end of the HTML document _(this one I’ve already tried and worked)._
2. I could load the whole script at the end of the HTML document.
3. I could define the variables being empty and then create their values after the page load.