Setting Up JavaScript
To write JavaScript you need two things: a place to type code and a place to run it. This lesson sets up the three places professionals use every day: the browser console for quick experiments, Visual Studio Code for real files, and Node.js for running JavaScript outside the browser. The whole setup is free and takes about fifteen minutes.
In One Minute
- The browser console runs a line of JavaScript instantly. Open it with F12 (Windows) or Cmd+Option+J (Chrome on a Mac).
- Visual Studio Code (VS Code) is a free editor; save code in
.jsfiles and link them from an.htmlpage. - Node.js runs
.jsfiles from the terminal withnode file.js. This course uses Node.js 26, the current LTS (long-term support) version. - Every example in this course also has a Try it button, so you can start before installing anything.
The Browser Console
Every browser has developer tools (DevTools) with a Console panel. It is a scratch pad: type an expression, press Enter, see the result.
| Browser | Windows / Linux | Mac |
|---|---|---|
| Chrome, Edge | F12 or Ctrl+Shift+J | Cmd+Option+J |
| Firefox | F12 or Ctrl+Shift+K | Cmd+Option+K |
| Safari | (enable it first) | Turn on Show features for web developers in Settings, Advanced; then Cmd+Option+C |
Try typing these lines one at a time:
2 + 3
"Fee Tracker".toUpperCase()
console.log("Hello, Srihitha")The console shows 5, then 'FEE TRACKER', then prints Hello, Srihitha followed by undefined. That last undefined surprises people: the console shows the value of every expression you type, and console.log(...) prints its message but has no value of its own.
An Editor and a Web Page
For anything longer than a line, write files. Install Visual Studio Code from code.visualstudio.com, then create a folder named fee-tracker with two files:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fee Tracker</title>
<script src="app.js" defer></script>
</head>
<body>
<h1>Fee Tracker</h1>
</body>
</html>console.log("Fee Tracker loaded");Double-click index.html to open it in your browser, then open the console: you see Fee Tracker loaded. Each time you change app.js, save and reload the page.
A small extension makes this faster: Live Server (or any "live preview" extension) serves the folder and reloads the page whenever you save. Opening files directly (a file:// address) works for this lesson, but later lessons that use fetch or modules need a real local server, because browsers block those features for local files.
Node.js: JavaScript in the Terminal
Node.js is a runtime that runs JavaScript outside the browser. You will use it to run examples, scripts and tests.
- Go to nodejs.org and download the LTS version. As of November 2026 that is Node.js 26 (Active LTS since October 28, 2026, supported until April 30, 2029).
- Run the installer. On macOS you can instead use a version manager such as
nvm, which lets you switch versions per project. - Check the installation in a terminal:
node --versionv26.13.1Your number may be newer than v26.13.1; any v26 is fine. Now run a file. Save this as hello.js:
const student = "Advitha";
console.log(`Hello, ${student}! Node.js is ready.`);Hello, Advitha! Node.js is ready.Then run it from the folder that contains it:
node hello.jsTwo Useful Node.js Habits
node --watch hello.jsreruns the file every time you save it, like Live Server for scripts.nodeon its own opens the REPL (read, evaluate, print loop), which works like the browser console. Type.exitor press Ctrl+D twice to leave.
Reading Your First Error
Everyone's code fails. The skill is reading the error. Run this:
const fee = 120;
console.log(Fee);ReferenceError: Fee is not definedThe message has two parts: the error type (ReferenceError, meaning a name that doesn't exist) and a description (Fee is not defined). JavaScript names are case-sensitive, so Fee and fee are different names. In the browser console and in Node.js, the error also shows the file name and line number, so you know exactly where to look.
| Error type | Usually means |
|---|---|
SyntaxError | The code isn't valid JavaScript: a missing bracket, quote or comma |
ReferenceError | A name that doesn't exist: a typo, or a variable used outside its scope |
TypeError | A value used the wrong way: calling something that isn't a function, reading a property of undefined |
Common Mistakes
Running Node.js on the wrong folder. node hello.js looks in the terminal's current folder. If you see Cannot find module, use cd to move to the folder that contains the file.
Forgetting to save or reload. The browser runs the file as it was when the page loaded. Save in the editor, then reload the page (or use a live preview extension).
Installing an odd-numbered or end-of-life Node.js. Node.js 25 reached end of life on June 1, 2026 and gets no security fixes. Use the LTS line.
Typing node hello.js inside the Node.js REPL. That is a terminal command. If you see a > prompt, you are in the REPL; leave it with .exit first.
Practice
Challenge: Create receipt.js that stores a student name and a fee in two variables, then prints Receipt for Navika Anamaneni: $120. Run it with Node.js, then change the fee and run it with node --watch to see it rerun on save.
Show solution
const name = "Navika Anamaneni";
const fee = 120;
console.log(`Receipt for ${name}: $${fee}`);Receipt for Navika Anamaneni: $120Key Takeaways
| Task | How |
|---|---|
| Open the console | F12, or Cmd+Option+J in Chrome on a Mac |
| Check Node.js | node --version |
| Run a file | node hello.js |
| Rerun on save | node --watch hello.js |
| Open the REPL | node (leave with .exit) |
Was this tutorial helpful?