Hello! Welcome to our fourth lesson.
In our last session, we explored the concept of JavaScript runtime environments, learning how JavaScript code is executed in two distinct places: the browser for user-facing interactivity and Node.js for server-side logic. You now understand that while they share the same V8 engine, they provide different tools (APIs) for different jobs.
Today, we're moving from theory to practice. The goal of this lesson is to get your computer ready for writing and running your own JavaScript code. We'll set up your local development environment, which is the collection of tools on your own machine that you'll use throughout this course. Specifically, you will learn how to:
- Install and navigate a professional code editor: Visual Studio Code (VS Code).
- Find and use the browser's developer console, your primary tool for testing code and seeing output in these early stages.
By the end of this lesson, you will have the complete setup needed to start your programming journey.
Part 1: Your Digital Workshop - Visual Studio Code
Before you can write code, you need a place to write it. While you could technically use a simple text editor like Notepad, developers use specialized tools called code editors. A code editor is like a word processor designed for programming, with features like syntax highlighting (coloring code to make it readable), auto-completion, and error checking.
The most popular code editor in the world for web development is Visual Studio Code (VS Code), and it's what we'll be using.
Installing and Exploring VS Code
We'll start by installing VS Code and getting a tour of its interface. Since you prefer visual learning, the best way to do this is to follow a video guide.
VS Code for Absolute Beginners
The video 'VS Code for Absolute Beginners' by Coder Coder provides a fantastic step-by-step guide. We'll watch a few key sections to get you set up.
Please watch the following parts: Installation (00:00 - 01:38): Follow along to download and install VS Code on your computer. UI Tour (01:38 - 02:47): Pay attention to the names of the different parts of the interface: Activity Bar, Side Bar, Editor Panel, and Status Bar. This will help you navigate the application. Working with Files & Folders (02:47 - 04:50): This is a crucial section. Follow the instructions to create a new folder for our course projects on your computer (you could call it js-course) and open it in VS Code. Then, practice creating a new file within that folder.
As a supplement to the video, you can also refer to the official VS Code documentation. It provides the same information in a text-based format.
Tutorial: Get started with Visual Studio Code
The official 'Get started with Visual Studio Code' tutorial is a great reference to have. It covers the same ground as the video.
Skim through these sections to reinforce what you saw in the video: 'Prerequisites' (for the download link). 'Open a folder in VS Code'. 'Explore the user interface'. 'View and edit files with the Editor'.
By now, you should have VS Code installed and a new project folder opened within it. The key takeaway is that you should always open a folder, not just individual files. This tells VS Code that all the files in that folder are part of a single project.
Part 2: Your JavaScript Playground - The Browser Console
Now that you have an editor, you need a place to run your code. As we learned in the last lesson, the browser itself is a JavaScript runtime environment. Tucked away inside every modern browser are Developer Tools, and within those tools is the Console.
The console is your direct line to the browser's JavaScript engine. You can use it for two main things:
- Executing code on the fly: You can type JavaScript directly into the console and see the result instantly. This makes it a fantastic tool for quick experiments. It functions as a REPL (Read-Eval-Print Loop).
- Viewing output from scripts: You can write code in your
.jsfiles to send messages and data to the console, which is essential for checking your work and debugging.
Let's see how to access and use it.
The JavaScript Console Explained for Absolute Beginners
This video, 'The JavaScript Console Explained for Absolute Beginners' by Future Fullstack, gives a clear and simple introduction to the console.
Watch the first three minutes of the video: What is the Console? (00:12 - 01:27): The juice bar analogy here is a great way to understand the console's role as an interface to the JS engine. Opening the Console (01:27 - 02:30): Follow along to open the developer tools in your browser (right-click on a webpage and select 'Inspect'), then click on the 'Console' tab. Running Code (02:30 - 03:16): Try typing a simple math expression like 5 * 10 into the console and hitting 'Enter' to see it work.
To reinforce this, the following article provides quick, text-based instructions for opening the console in different browsers and shows more examples of running code.
Running JavaScript in the Browser Console
Codecademy's article 'Running JavaScript in the Browser Console' is a handy cheat sheet for accessing and using the console.
Quickly read the sections 'Opening the browser console' and 'Example #1: Performing basic arithmetic'. This will solidify how to open the console and use it as a basic calculator.
Part 3: Connecting Your Editor to the Browser
You now have a code editor (VS Code) and a place to see your code's output (the browser console). The final step is to connect them. We will write a piece of JavaScript in VS Code and make it run in the browser.
To do this, we need a basic HTML file to act as the "host" for our JavaScript file.
Step-by-Step Guide
Follow these steps inside VS Code, within the project folder you created earlier.
- Create an
index.htmlfile: In the VS Code explorer sidebar, create a new file namedindex.html. - Add HTML Boilerplate: In the
index.htmlfile, type!and pressEnter. VS Code will automatically generate a basic HTML structure for you. - Create a
script.jsfile: In the explorer, create a second file namedscript.js. This is where our JavaScript code will live. - Link the files: Go back to
index.html. Just before the closing</body>tag, add the following line:
This tag tells the browser to find, load, and execute the code inside<script src="script.js"></script>script.js. - Write your first line of JavaScript: Go to the
script.jsfile and type:console.log('Hello from my script file!');console.log()is a built-in function that prints whatever you put inside the parentheses to the console.
The following video segment walks you through this exact process.
The JavaScript Console Explained for Absolute Beginners
Let's return to the 'JavaScript Console Explained' video, as it demonstrates exactly how to link an HTML and a JS file.
Watch from 05:15 to 06:10. This part shows how to create the index.html and script.js files, link them with a <script> tag, and write a console.log() message.
Now, to see the result:
- Find the
index.htmlfile on your computer (inside your project folder). - Double-click it to open it in your web browser. You'll see a blank white page, which is expected.
- Open the developer console (right-click -> Inspect -> Console).
You should see your message: "Hello from my script file!"

Test your understanding!
Now it's your turn to practice the full cycle.
- Go back to your
script.jsfile in VS Code. - Change the message inside
console.log()to something new, for example:console.log('This is my first real program!'); - Save the
script.jsfile (Ctrl+S or Cmd+S). - Go back to your browser, and refresh the
index.htmlpage. - Check the console. Does it show your new message?
Show answer
If you followed the steps correctly, your browser console should now display "This is my first real program!". This edit-save-refresh cycle is the fundamental workflow for front-end web development. Every time you change your code, you must save the file and refresh the browser to see the changes.
(Pro tip: The 'VS Code for Absolute Beginners' video you watched earlier mentions an extension called Live Server (at 22:42). Installing it adds a "Go Live" button to VS Code that opens your HTML file and automatically refreshes the browser every time you save. This is highly recommended to speed up your workflow!)
Conclusion
Congratulations! You have successfully set up a professional development environment. This is a huge and essential first step.
Key Takeaways:
- A code editor like VS Code is a specialized tool for writing code.
- The browser console is an essential part of the developer tools that allows you to run JavaScript code and see output from your scripts.
- An HTML file can include a JavaScript file using the
<script>tag. - The
console.log()function is your primary tool for printing information to the console to verify that your code is working as expected.
You now have the tools and the workflow in place to start building. In our next lesson, we will focus entirely on the console.log() command, using it to write your first simple programs and understand how JavaScript handles basic data.