Skip to main content

Creating hello.js

1

Create a project folder

Open your terminal and create a folder for your practice files:
2

Create the file

Open this folder in VS Code:
Create a new file called hello.js and add this code:
hello.js
3

Run it

Open the integrated terminal in VS Code (Ctrl+`) and run:
That’s it. You just wrote and ran a JavaScript program.

What’s happening here

  • const declares a variable (you’ll learn more in the JavaScript Core section)
  • console.log() prints output to the terminal — JavaScript’s version of Python’s print()
  • Backticks ` with ${} let you embed variables in strings — like Python’s f-strings

Try the browser console

You can also run JavaScript directly in your browser. Open any browser, press F12, and click the Console tab.
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.

What’s next?

You’ve run JavaScript in two places — Node.js and the browser console. Let’s explore the different ways to run JavaScript during development.

Running JavaScript

All the ways to run JavaScript code