Ok, so the console can show us things but nothing is really changing on the actual page. Can't we do something that is actually visible to the user of the page?
Of course we can.
We will start by actually adding the script to our page.
The script tag itself may be placed in the head or the body element, but I recommend you place it in the body element just before the end body tag. Why? If the script needs to work with elements that are on the page, it won't find them if placed in the head element or above the content. The browser will run the script when it sees it. As long as we don't have the necessary knowledge to make the script wait for the page to finish loading, placing the script in the bottom of the page is therefore your best option.
Notice the code block inside the script element.
The method console.log() is used to print to the console. Whatever is written inside the parentheses is what is printed.
I recommend that you do not use internal script but keep HTML and JS (and CSS) separated. It will make the code easier to understand:
Placing the script tag in the bottom of your HTML, just before the end body tag is still your best option.
In this example, the src attribute is added to the script start tag.
The file we request in the example is placed in a subfolder called js, and the file itself is named script.js.
NB: Avoid spaces when naming your files.
Create a basic HTML file and save it in a folder.
Place the script element inside the body element, jus before the end body tag
Use console.log() to log the string Hello World! to the console
Test that is works by opening up the page in the Chrome browser and from there opening the console. If Hello World is visible in the console, you have succeeded with the assignment.
Test that it works - If Hello World is still visible in the console when you refresh the page, you have succeeded with the assignment.