Open your terminal and create a folder for your practice files:
Copy
mkdir js-practicecd js-practice
2
Create the file
Open this folder in VS Code:
Copy
code .
Create a new file called hello.js and add this code:
hello.js
Copy
const name = "Sarah";const language = "JavaScript";console.log(`Hello, ${name}!`);console.log(`Welcome to ${language} for Web Dev.`);console.log("Let's build something.");
3
Run it
Open the integrated terminal in VS Code (Ctrl+`) and run:
Copy
node hello.js
Copy
Hello, Sarah!Welcome to JavaScript for Web Dev.Let's build something.
That’s it. You just wrote and ran a JavaScript program.
You can also run JavaScript directly in your browser. Open any browser, press F12, and click the Console tab.
Copy
// Type this directly in the browser console:console.log("This runs in the browser!");2 + 2// 4
The browser console evaluates expressions immediately and shows the result. You don’t need console.log() for simple expressions — the console shows the return value automatically.
Use the browser console for quick experiments. Use .js files with Node.js for anything you want to save.