1.4 Separation of concerns and Execution in Node
So now after writing javascript code between the script elements we will extract is separate our javascript code from our html code. Why? I'll give you an example. Think about your house, in your room you have your, bed and clothes, you don't store your clothes in the kitchen. We have the same principle in programming, we want to separate the html which is all about the content. From the JavaScript which is all about the behavior, this is what we call the separation of concerns. Create a new file. Call it index.js And we're going to move this code. Into that file. Once it's done. We need to reference and file here. we add an attribute. "src" it's an abbreviation of source that we'll set on the index.js This tells the browser that our JavaScript code is now in the index.js. In our console, we will check That we have the same message as before. After executing this piece of JavaScript code inside the browser, we will see how to execute it in Node, I suppose you already have Node in your machine and if not, I invite you to join nodejs.org and download the latest version of Node. We will open the command prompt that corresponds to Node. And we point to the folder of our project. Node Index.js. There we have the same message. That's it for this chapter we'll meet again for the next video where I'll talk about variables in JavaScript.