To do this we need to create an HTML file. You can call it what ever you want and we just need to put our basic HTML here.  In this example we will give it a name index.html . We do not have to put anything here if we do not want to but just to make it clear its the same page we are going to put a h1 tag.

Just like any other site we can open up the console and start writing some JavaScpript here. But the whole point is
that we are going to write JS in a separate file. To do that we are going to create a new separate file that we are going to name index.js (just like HTML and CSS you can name it what ever you want) and save it in the same directory as the HTML. file. The important part is the .js part. That tells the browser, the text editor you are using like Sublime, Atom, Visual Studio Code etc. that this is a JavaScript file.

If we put a single line JavaScript here like alert(“Hello from Den Of Developers”) and see if its working right and
refresh the page it will do nothing because its not connected. To do that we use the script tag. Script tag is not self
closing so we need to have a closing tag and then we need the source (src) attribute. That source attribute needs to be the equal to the file that we want to load.

Now if we hit refresh we will get a pop up or alert that says Hello from Den Of Developers and any time we refresh the page we get the same pop up automatically.

In the next part we are going to start talking about Data Types in JavaScript.

Spread the love

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *