Hello World | Bondar Academy
Course: JavaScript for Testers
Module: JavaScript Fundamentals
Instructor: Artem Bondar
Lesson Summary
This lesson introduces the traditional Hello World application, a common first project when learning a new programming language. Here’s a step-by-step summary of the process: Setting Up the Environment Create a new folder named JS Fundamentals on your computer. Ensure that your development environment is configured with Node.js and Visual Studio Code installed. Creating the Project Open Visual Studio Code and load the empty folder you created. Open the terminal in VS Code by selecting Terminal > New Terminal . Run the command npm init to create a package.json file, which is the configuration file for your Node.js application. Accept the default values by pressing Enter multiple times until the file is created. Creating JavaScript Files Create a new folder named lessons inside the JS Fundamentals folder. Create a new JavaScript file named lesson1.js in the lessons folder. Writing and Running the Code In lesson1.js , write the following code: console.log('Hello World'); To run the code: Change to the lessons folder in the terminal using cd lessons . Execute the file with node lesson1.js . Upon running, you should see Hello World printed in the console, confirming that your first program is working. In the next lesson, you will continue to explore more JavaScript examples.
Video Transcript
And we begin our lessons with a simple Hello World application. Hello World is a tradition for the programming languages. When you begin learning a new programming language, you write application Hello World. And this is what we're gonna do in this lesson. So let's get into it. We will create a new folder on our computer. Let's say we name it JS Fundamentals. And by the way, if you are on Windows computer, you are doing pretty much all the same thing. And of course, by this time, your dev environment should be configured. So Node.js should be set up, VS Code should be installed according to the previous instructions. So the folder is created. Now let's open application Visual Studio Code. And here is the new window right here. And right now we just need to open this empty folder that we just created. I go to the File, Open Folder, and on the desktop, I have JS Fundamentals folder creating. Click Trust the authors, and as we can see, it's just empty, right? Nothing is here. So we click on the terminal in VS Code, New Terminal. Now let me make this a little bit bigger so it will be easier to see. So inside of the terminal, we will type the command npm init and click Enter. NPM will offer us to create some default parameters for our file package.json. Package.json is a configuration file for the Node.js application. So in the braces, it gives us a default values that we want to use, or we can provide our own values. So let's use a default values. So we're just simply clicking Enter, Enter, Enter, Enter, Enter, Enter, Enter, and all the Enter. And it says, is everything look okay for us? We click Enter one more time. Yes. And the new package.json was created. So it's just the layout, how the package.json look like. Usually in the Node.js applications, you will see two more sections called dependencies. We need to put comma right here. And underneath, one more section called dev dependencies. Usually inside of these two sections, you will put the third-party libraries that are needed to run your application. So we will not use them now, but just for your information, package.json in Node application. This is a main configuration file. We don't need it right now. Let's close it. Let's create a new folder where we will put our JS files. I click on this icon and create folder lessons. Okay. And inside of this folder, I create a new JavaScript file and call it lesson1.js. Okay. We created a first file and we're ready to write our code. So I call it hello world. This is just the title of this code section. And the first line of code that we will write and execute will be console.log. And we will print the message into the console that we want. This message will be hello world. And that's it. Now, how to run this? In our terminal, we need to switch to the folder that we just created. So currently we are in the root, which is JS fundamentals folder. We need to switch to the lessons folder. We do cd space lessons, click enter. And you can see that in terminal, we switch to the lessons folder. And now I just do node space lesson1.js, run it. And here we go. Our code is working. We printed a message to the console, which is hello world. All right. So in this little project, we will continue to run new JavaScript code and new JavaScript example. Our first program, hello world, is working. You know how to run this JS file. So see you in the next lesson.