Lesson goal: Prepare your project folder and open the browser console.
To begin, you need two main tools: a code editor and a web browser. This lesson will help you to Set Up Your Editor effectively.
We will use Visual Studio Code and Google Chrome in these instructions. Therefore, make sure you have both installed on your computer.
First, download Visual Studio Code from the official Visual Studio Code website. If it is already installed, open it to Set Up Your Editor correctly for this project.
Also, VS Code includes JavaScript editing support. Therefore, you do not need an extra JavaScript extension for these introductory exercises. Check the VS Code JavaScript documentation for more details.
Next, create a folder named:
student-profile
In VS Code:
student-profile folder.Then, use the New File button in the Explorer panel to create:
index.html
style.css
script.js
Ensure that you check the extensions carefully. For instance, your JavaScript file must be script.js, and not script.js.txt.
Next, in Chrome on Windows:
Alternatively, you can right-click a page, choose Inspect, and select the Console tab.
On macOS, Chrome’s Console shortcut is Command + Option + J. Consult the Chrome DevTools instructions for further guidance.
Now, type this into the Console and press Enter:
10 + 5
15
console.log("I am ready to learn JavaScript.");
I am ready to learn JavaScript.
undefined after this command. That is the return value of console.log(), not an error.Console code versus saved code
| Code entered in the Console | Code saved in script.js |
|---|---|
| Useful for quick experiments | Useful for building your project |
| Does not become part of your project file | Remains saved in your project |
| Does not automatically rerun after refresh | Runs when the page loads the connected script |
Your turn
Use the Console to:
25 + 75."This is my first JavaScript practice.".Your editor is where you save code. Meanwhile, your browser is where you run the page. As a result, the Console helps you see what your JavaScript is doing.