How do I get JavaScript code to execute in Chrome from an HTML document?

Very basically, how do I get JavaScript code to execute in my browser? I am working
through a book which asks me to embed my JS code between tags in an HTML file, like this:

<!DOCTYPE html>
    <body>
        <script>
            console.log("Hello");
        </script>
    </body>
</html>

My browser will still run JS code which involves the alert() method, and a pop-up will be displayed on the screen as expected. Seemingly anything involving the console.log() method will not display.

When I attempt to open the file in Chrome, I just get a blank page with no printout.
I have opened the file in the JavaScript console and no errors are reported (I get the
printout of the string “Hello” as expected). Previously I had an error which I resolved by adding !DOCTYPE inside the opening HTML tag.

I have Googled for answers and ensured that JavaScript is enabled in the Chrome privacy settings as directed. I’ve also looked on Stack Overflow, but haven’t found anything which allows me to solve the problem at such a basic level.

What am I missing here? Sorry if this seems like a very elementary question – I am new to this language.

I’m on Windows 11, running Chrome 131.0.6778.70 (the most recent version – I have updated as part of the troubleshooting process). Please let me know if any further information is needed.

Thanks in advance.