You must have some knowledge of HTML and CSS to learn JavaScript.
You can add JavaScript to your web page by using three ways:
1. You can Embed the JavaScript code between a pair of <script> and </script> tag.
For Example
<script>
var greet = "Hello World!";
document.write(greet);
</script>
Output
2. You can create an external JavaScript file with the .js extension and then load it within the page through the src attribute of the <script> </script> tag.
For Example
<button type="button" id="myBtn">Click Me</button>
<script src="/assets/tutorial_demo_test/test.js"></script>
Output
3. You can also place JavaScript code inside the HTML tag by using the special tag attributes such as onclick, onmouseover, onkeypress, onload, etc.
For Example
<button onclick="alert('Hello World!')">Click Me</button>
Output
