For real projects, keep JavaScript in separate .js files. Create a file called script.js and link it with the src attribute:
<script src="script.js"></script>
This separation has benefits. First, your HTML stays clean and readable. Second, browsers can cache the JavaScript file, making repeat visits faster. Third, you can reuse the same script across multiple pages.