In this tutorial I shall teach you how to run JavaScript in visual studio code. For this tutorial I am using Linux, Ubuntu operating system. So I shall mostly use a terminal to install some of the programs.
Before running Javascript in visual studio code, we need to install NodeJs in our machine. For this follow the below steps to installing the NodeJs.
sudo npm install nodejs
If you already installed then the the following things will be shown in the screenshot below.

Then check the npm and node version by typing the following commands
node -v
npm -v

The above result will be shown when you type those two commands to check the node and npm version.
Now you need to install the Visual Studio Code into your computer. There are also very simple steps to installing the Visual Studio code into your machine.
Simply type the following command to install the Visual Studio code to your machine.
sudo snap install code –classic
And now you are ready to run your first JavaScript program in Visual Studio Code.
Now follow these steps to run JavaScript in Visual Studio Code.
Step 1
Open Visual Studio code program

When you install it for the first time in your computer the above display will be of Visual Studio Code.
Step 2
Now Create a folder on the desktop which is named “js-program”. Go to File -> Open Folder And select the folder which you created from desktop by using the browser window. And click ok.
Now that folder will be opened to your Visual Studio Code Like below screenshot.

Step 3
Now right click on below of your folder name and click on “new file” option. And name that file as “index.js”. And hit Enter key a new file will be opened to your web browser like the below screenshot.

Step 4
Now write the code like below screenshot in that “index.js” file.

Step 5
Press “CTRL+S” Key to save the file.
Now go to terminal -> new terminal to open and create a new terminal window. On the bottom side of your Visual Studio Code a tab will be shown like the screenshot below.

Step 6
In terminal type the following commands to run your index.js file.
node index.js
When you type the above command the “Hello JavaScript” message will be shown after the command which you have written in your “index.js” file, like the screenshot below.

Congratulations!
You have learned “how to run JavaScript in visual studio code”.