I have two files in a folder- one is index.html and the other is myscript.js. The index.html is not finding the javascript. The content of both files are as follows-
Because you are loading the script at the top of the page, before the button has been loaded in the browser, the browser can’t set a value for the button var, because when it looks, there’s no button.
The standard practice these days is to attach the script to the bottom of the file—which is the easiest way to deal with this: