JavaScript 2 🧬 How to add JavaScript
a - Add Javascript to HTML
There are two ways to add JavaScript in an HTML file
1 → by embedding JavaScript in the HEAD or BODY section
2 → by linking to an external JavaScript file
You may also find inline JavaScript handlers like onclick="showSomething()" in an HTML element
But this way is not recommended. Instead it is better to addEventListener to HTML element in Javascript.
Placing the JavaScript in the BODY section ensures that the code will be executed after all the HTML body is parsed