Skip to content
C Codeloom
JavaScript

JavaScript Setup: Browser Console, Node.js, and Your First Program

Run JavaScript in your browser's console, install Node.js, set up VS Code, and write three working first programs — all in under fifteen minutes.

·7 min read · By Yash Kesharwani
Beginner 9 min read

What you'll learn

  • How to open and use the browser developer console
  • How to install Node.js and verify it works
  • How to run a .js file from the terminal
  • How to set up VS Code for JavaScript
  • Three first programs that prove your setup works

Prerequisites

The fastest way to get started with JavaScript is to write it directly in a browser you already have open. There is nothing to install, no project to configure — just a console and a prompt. This post walks through three environments where you will run JavaScript throughout the series, in order of increasing power: the browser console, Node.js from the terminal, and a .js file run from VS Code.

By the end you will have run three small programs and confirmed your setup works.

Option 1: The browser developer console

Every modern browser ships with a built-in JavaScript console. It is the quickest possible way to try a snippet of code.

On any web page, open the developer tools:

  • Chrome, Edge, Brave: press F12, or right-click and choose Inspect.
  • Firefox: press F12, or right-click and choose Inspect.
  • Safari: enable the Develop menu in Settings → Advanced, then press Option + Command + I.

Click the Console tab. You will see a prompt — usually a > — waiting for input.

Type:

console.log("Hello, world!");

Press Enter. The text Hello, world! appears. You have just run your first JavaScript program.

Try a few more lines to get a feel for the console:

2 + 2
"hello".toUpperCase()
new Date().getFullYear()

The console prints the result of each expression. This is the fastest scratchpad in programming, and you will use it constantly even after you become a professional.

Try it yourself. Open the console on any web page right now. Type document.title and press Enter. The browser will print the title of the current page. Then type document.body.style.background = "lightblue" and watch what happens. Refresh the page to undo it.

Option 2: Node.js from the terminal

The browser console is great for snippets, but for real programs you want a runtime that can read files, talk to a database, or run scripts on a schedule. That runtime is Node.js.

Installing Node.js

Go to nodejs.org and download the LTS (long-term support) version. As of writing, that is Node.js 22. The installer is a few megabytes and takes under a minute.

  • Windows: run the .msi installer, click through, accept the defaults.
  • macOS: run the .pkg installer, or brew install node if you use Homebrew.
  • Linux: use your package manager, or follow the official Node.js install guide.

Once installed, open a terminal (Command Prompt or PowerShell on Windows; Terminal on macOS/Linux) and check both Node and npm are available:

node --version
npm --version

You should see two version numbers, for example v22.11.0 and 10.9.0. If you see them, you are ready. If not, restart the terminal and try again.

The Node REPL

Type node with no arguments to enter the REPL — an interactive prompt much like the browser console:

$ node
Welcome to Node.js v22.11.0.
> 2 + 2
4
> const name = "Ada"
undefined
> `Hello, ${name}`
'Hello, Ada'
> .exit

Press Ctrl + C twice, or type .exit, to leave.

Option 3: Running a .js file

For anything more than a few lines, save your code to a file and run it from the terminal.

Create a folder for the series — call it js-basics — and inside it create a file called hello.js with these contents:

const name = "world";
console.log(`Hello, ${name}!`);
console.log(`The current year is ${new Date().getFullYear()}.`);

Open a terminal in that folder and run:

node hello.js

You should see:

Hello, world!
The current year is 2026.

That is the workflow you will use throughout the series — write code in a file, run it with node filename.js, read the output, iterate.

Setting up VS Code

You can technically use any text editor — Notepad, TextEdit, anything — but Visual Studio Code is free, fast, and the de facto standard for JavaScript work.

  1. Download VS Code from code.visualstudio.com and install it.
  2. Open it, then open the folder you created (File → Open Folder, pick js-basics).
  3. Open the built-in terminal with Ctrl + ` (backtick) — or View → Terminal.

That single window now contains everything: your file tree on the left, your code in the middle, and a terminal at the bottom to run it. You will rarely need to leave.

Two extensions are worth installing right away:

  • ESLint — flags syntax errors and common mistakes as you type.
  • Prettier — auto-formats your code on save so you stop arguing about whitespace.

Both are free and one-click installs from the Extensions panel.

Try it yourself. In VS Code, create a file called greet.js that asks Node to print three lines:

  1. Your name
  2. Today’s date
  3. A multiplication: 12 * 17

Run it with node greet.js. Use template literals (backticks) for the strings.

A slightly larger first program

To prove the setup end-to-end, here is a small program that does something useful. Save it as report.js:

const names = ["Alice", "Bob", "Carol"];
const scores = [82, 47, 91];

const average = scores.reduce((sum, n) => sum + n, 0) / scores.length;

console.log("Report");
console.log("------");
for (let i = 0; i < names.length; i++) {
  const status = scores[i] >= 60 ? "pass" : "fail";
  console.log(`${names[i]}: ${scores[i]} (${status})`);
}
console.log(`Average: ${average.toFixed(1)}`);

Run it:

node report.js

Expected output:

Report
------
Alice: 82 (pass)
Bob: 47 (fail)
Carol: 91 (pass)
Average: 73.3

Every concept in those ten lines — variables, arrays, arrow functions, loops, template literals, the ternary ? : operator — will be covered in detail in upcoming posts. The point right now is that it works and the output makes sense.

Browser vs. Node: when to use which

A short rule of thumb you can use immediately:

  • Browser — anything involving a web page, the DOM, user clicks, or visible output. The browser console is also fine for trying a snippet.
  • Node.js — anything that reads files, calls APIs, talks to a database, runs on a schedule, or builds command-line tools. Most of the early posts in this series use Node.

Every code example in this series runs unchanged in both environments unless we explicitly say otherwise. JavaScript itself is the same; the surroundings differ.

Troubleshooting

A few problems you might hit:

  • node: command not found — Node isn’t on your PATH. Restart the terminal; if it persists, reinstall Node and choose the option that adds it to PATH (default on Windows).
  • SyntaxError: Unexpected token — almost always a missing bracket or quote a few lines above the reported one. Read backwards.
  • The console prints undefined after your code — that’s the REPL telling you the expression itself returned no value. Harmless. console.log does its work as a side effect; the call itself returns undefined.

Recap

You now know:

  • How to open the browser developer console and run JavaScript in it
  • How to install Node.js and confirm node --version works
  • How to write a .js file and run it with node filename.js
  • How to set up VS Code with an integrated terminal
  • The rough division of labour between browser and Node

Next steps

You have a working environment. The next post starts the language proper — how to store values in variables using let and const, why var exists but should be avoided, and the rules for naming things.

→ Next: Variables in JavaScript: let, const, and var Explained

Questions or feedback? Email codeloomdevv@gmail.com.