JS Function in External File

My project is at https://groovy-star-fountain.glitch.me/ and I need a bit of help. I am trying to refer to an external .js file and change an HTML element based on the results. I don’t know why my in the HTML document isn’t working, but I think that’s the issue because the function in question (which just changes the text in a span) runs if I put the script directly in the HTML, but doesn’t work if I’m trying to call it from my external JS file. Could someone look at the code and tell me where I’m going wrong? This should be super simple but it’s frustrating me.

Your game.js file returns 404 instead of 200 (OK)

You can use express to make a folder be “static,” then you could use it.

2 Likes

Thanks! That was great!

1 Like