To add JavaScript to a webpage, use the <script> tag. You can write code directly between the opening and closing tags:
<script>
console.log("Page loaded")
</script>
Place script tags at the end of your HTML body. This ensures the page content loads before your JavaScript runs. If you put scripts in the head, they might try to access page elements that don't exist yet.