Let's figure out how to write your first JavaScript code.
It's pretty simple and you will see it now.
In order to do that, we need some to end our JavaScript code to estimate that we have different ways
to write JavaScript.
You remember that we have created the folder called JavaScript and also the index estimate extremophile
in previous video.
Let's open it in brackets.
You can see here the very basic structure of HTML documents.
I hope that you already know at least the basics of HDMI.
If you don't, then I recommend to introduce the ABC of that technology.
All right, let's go ahead and run this file.
Google Chrome.
So you can see here on the page the heading, which tells us the title of the lecture, it's written
inside the body elements using H1 in text.
At first let's organise brackets and Browsr nicely.
I like working this way because it saves our time so you can use this technique to to write JavaScript
code, we have to open the script text.
But before that, let's turn off life preview mode.
Because it's very handy when you work on e-mail and access, but now we don't need it, so let's write
script tax, which should be placed above to the closing estimate that we can physically replace them
almost anywhere in HTML.
But this one is the best practice that helps browser to load Web page.
Foser this way is called inline method because we write JavaScript and HTML in the same file.
That's right.
Our very first line of code.
Cancel that log.
And Hello World.
Now, open the counsel tab, I hope you remember how to do that.
There are three ways.
Let's use one of them, click on Inspect and you can see the text.
Hello, world.
You can also notice you're on the right side, that this text is placed on the 11th line in Ed Consul
Tab is the great tool for testing, debugging the applications and for getting the results and outputs
throughout the course will be working in Castlebury frequently.
All right.
Let's figure out how actually the code works.
When we launched the documents, browser can read the content of HTML, but to read and execute JavaScript
code, it needs something to translate it.
Imagine that you can't understand the foreign language and your friend is helping to translate the language.
Browser has such front, which is JavaScript engine and it's already built in browsers.
Let's explain it deeper.
Browser is reading HTML code line by line when it switches to script.
Text browser understands that the content inside script text is not any more HTML and it caused the
engine to translate.
It makes sense.
All right.
The next way to write JavaScript is an external method, we need to create another file in our folder,
let's call it cryptologists.
The extension of JavaScript files should be Duchesse.
In order to connect JavaScript file to HTML, we need to create the link between them.
Let's do that.
Delete this line of code because we don't need it anymore than inside.
The opening script tag indicates the directory of cryptologist file.
For that we have to use source, attribute and the path of JavaScript file.
Now open this cryptologist file and write the same code here.
Castle, good luck.
Hello, world.
Reload the page and you can see that we've got the same hello, Walt.
You can use either in line or external methods, both work fine, but the second one is better practice
because it's more organized.
And when you need, for example, the same JavaScript code for multiple pages, you can write it once
and then link the JavaScript file to all Actimel pages.
All right, so in this election, we have learned how to write JavaScript using inline and external
methods.
Also, we have discussed how the process works.
So let's move on.