Setting Up the JavaScript Environment


Before we write any JavaScript code, let’s set up a proper environment for coding and testing. You don’t need any fancy tools to get started — just a browser and a text editor!



Option 1: Quick Start in the Browser

The easiest way to try JavaScript is directly in your web browser!

Steps

  • Open your browser (Chrome, Firefox, Edge, etc.)
  • Right-click anywhere on a page and choose Inspect or press Ctrl + Shift + I (Windows) or Cmd + Option + I (Mac).
  • Click the Console tab.
  • Type JavaScript code like:
console.log("Hello, JavaScript!")

And hit Enter — you’ll see the result instantly!



Option 2: Using a Code Editor (Recommended)

For serious coding, use a code editor. The most popular one is:

Steps to set up:


1. Download & Install VS Code

2. Create a Project Folder

  • Create a folder on your computer (e.g., my-js-project) and open it in VS Code.

3. Create an HTML & JS File

  • index.html – your basic HTML file.
  • script.js – your JavaScript file.

Example index.html:

<!DOCTYPE html>
<html>
<head>
  <title>My JS Project</title>
</head>
<body>
  <h1>Hello World</h1>
  <script src="script.js"></script>
</body>
</html>


Example script.js:

console.log("JavaScript is working!");
            

4. Open the HTML file in a browser

  • Just double-click index.html or use the Live Server extension in VS Code for real-time preview.