So I was getting an error in which the js file was not getting loaded in the “sources” tab of chrome dev tools. So whenever such a thing happens i.e a particular file is not getting loaded, the best approach is to make sure that the file path you are providing is correct or not and the way you are including it in the index.html is correct or not. The thing I noticed was that no doubt there was no syntax error being shown while running the index.html on a live server, the syntax which I was using to include js was wrong.
So the correct syntax is:
Thank you! I hope this was helpful!