Split javascript file into multiple files that share functions and variables

I’m currently working on a web app, and my index.js file is getting too big and confusing, and I was wondering what the best way is to split it into multiple JS files that share variables and functions?

I want to use only pure JavaScript, I tried to link both JS files in the HTML file but they don’t share the variables.