JS error help
Hi, I'm looking for javascript help with this code here, this is the 2nd day that I reopen the project and I'm getting this error, and after the first day I tried to put the code for the .minute into its own if/else statement and it seemed like it fixed it, but the error has returned and I can't figure out why
![](https://utfs.io/f/2d4ec2ab-9e2f-458d-96c3-4c897bf2d905-4pl4mu.png)
![](https://utfs.io/f/a48274a8-a4ad-454c-b5cc-4bc1b918437c-4pl4mu.png)
![](https://utfs.io/f/80aa8eb5-3a32-45fc-911f-f978fe4d648f-4pl4mu.png)
![](https://utfs.io/f/d4668a84-bd41-48e6-819b-848df1f23964-4pl4mu.png)
1 Reply
you probably have to add
defer
to your script tag. If you include your JS in your <head>
, the code can run before the DOM is ready and querySelector
won't work. If you change <script src="./main.js">
to <script src="./main.js" defer>
, the browser knows you want to wait to run the javascript until after the DOM is available.