Another way of running your JavaScript code is by using your browser. Whether you are using Google Chrome, or Firefox or any browser, you can run your JavaScript code. So for example, it's up in Google Chrome window. So as you can see, I have this window. Now, I'm going to click on, I'm going to just right click and click inspect. And I am going to have this elements.
And then besides it, I have a window, or I have a tab called console, click on it. And then here, you can type your JavaScript code and it's going to run immediately. So here, I'm going to use the same exact code that we use before, which is this one, console dot log. I'm going to copy it and I'm going to get back to our browser. And here what I'm going to do is I'm going to paste the same exact code and hit Enter. And as you can see, it says here, this is a test, which means that this code has been executed.
So this is another way of running or implement or executing your JavaScript code is by typing the code in the console. And of course, this is not the perfect way of doing so. Because most of the time, you will have a lot of code here. And it's difficult just to copy and paste. So it's important to use a text editor. And suppose that this risk code is very long and you want to and you want to execute it in the console or in the browser.
In other words, what you need to do instead is that you are not going to use a JavaScript code law, you are not going to use a JavaScript file like this, you first need to create an HTML file. So I'm going to create an HTML here, new file and call it Save it first Save As. And I'm going to call it index dot HTML. And I'm going to save it on my desktop. Alright. So now we have this index dot HTML on our desktop file.
And in order to add a JavaScript code into HTML file, what you need to do is you need to use tags, some kind of tags. And this tag that we are going to use is called script script. And then, as you can see, it's, you need just to open the script brackets and TypeScript and then the type text slash JavaScript, and then close the tag. And inside those tags, you need to add your JavaScript code. So here what I'm going to do is that I'm going to copy this code again. And I'm going to paste it inside.
And just for I'm just I'm going to add year, as simple as that. So that we know that we are running this HTML code in our browser. So here I'm going to type h1. And when I close the stack, and I'm going to type JavaScript, Java Script. And I'm going to save Click on Save. And finally, what I'm going to do here is that I'm going to go to Tools and build system.
And I'm going to change change the build system to Google Chrome. Here, I have Chrome, click on it, and then click on build here, this one build. And as you can see, now, the index that HTML file has been opened in our Google Chrome browser. Now if I get to the log, I'm going to right click and inspect. As you can see, on the on the console, I'm going to see this code. This is A test.
And I'm going to prove to you that JavaScript code is running by using a method called alert. I'm going to type alert, and then test, just test. And if I save and run again, or refresh, as you can see, I am going to get this pop up message saying tests, which means that our JavaScript code has been successfully executed. And if your code did not run for any reason, by using the build system here, by using the chrome build system, you just need to click on this file on HTML file, double click. And as you can see, it's going to up in in your browser. If now I click on the inspect again, I should see in the console, I should see the code this one and if I refresh, I'm going to see this popup message which says of tests.
And what that means is that these two lines of code have been executed, which means that JavaScript runs successfully. But in our course, we are not going to use this myth method. The method that we are going to use is we are going to use the build system here inside inside our Sublime Text, because it's the easier and because we are not going to use HTML at all in this course, this is a JavaScript code. So we are going to focus totally on JavaScript