NOTE: The other answers don't seem to work because I am not looking to just import or use a function from another file.
I need to know if there's any way I can put in something anywhere that tells another JS file to run. And the whole file.
I'm new to JavaScript and I'm trying to avoid things like NodeJS and jQuery so that I have a better understanding of JS, so I've tried making some simple programs.
I made a little game, but I want to put in another level. I tried making it so that once the collision is detected in a certain area, it will set a boolean that determines if the level is still running to false. Then I made a while loop that says that if it's on true, it updates the game. The problem is that this can't work as I've learned from other questions on this site. It crashes the whole thing. So I thought that if I can go back to my old game loop but put the other level in the file, I could call that file and have it basically be a separate game.
TL;DR: I need to know how to stop running one file and move onto another in JS, or at least redirect the user to a separate URL so that I can put the level in a separate site.