Share

Run simple JavaScript code in your Windows PC

by Mayank Goyal · 9 Jan 2025

1. Install Node.js:

Download the latest stable version of Node.js from the official website (https://nodejs.org/en/download).

2. Create a JavaScript file:

Open Visual Studio Code (or any editor) and write your JavaScript code.

JavaScript
function addNumbers(a, b) {
    return a + b;
}

// Example usage:
const num1 = 5;
const num2 = 10;
const sum = addNumbers(num1, num2);
console.log(`The sum of ${num1} and ${num2} is ${sum}`);

Save the file with a .js extension (e.g., addNumbers.js).

3. Run the JavaScript file:

Open VS code and open a Terminal.

Navigate to the directory where you saved your JavaScript file using the cd command.

Run the file using the following command:

node addNumbers.js


Discover more from Cloud Blogger

Subscribe to get the latest posts sent to your email.