Let's take a look at both methods:
As you can see just by including the <script> tag you can write any JS code you want and your browser will be able to read it.
Importing a JS file is very easy, the point is to create an external JS file and have all our JS code in it, then we import it into our HTML file.
This is a good idea since it makes the code look more cleaner and also allows us to choose which JS files to import in every page we want.
Let's take a look at this next example:
You can see from the above that including a "src" attribute in the <script> tag, will allow us to enter a location for the JS file we wish to import into our HTML file.