Intro to JavaScript Functions Setup
Open your Terminal application and navigate to your ~/code/ga/lectures directory:
cd ~/code/ga/lectures
Make a new directory called intro-to-javascript-functions, then enter this directory:
mkdir intro-to-javascript-functions
cd intro-to-javascript-functions
Then, create an app.js and an index.html file. These files will hold your work for this lecture:
touch app.js index.html
With the files created, open the contents of the directory in VS Code:
code .
Open the index.html file and add HTML boilerplate by typing ! and then hitting the Tab key. Then make use of the app.js file by adding this line inside the <head> tag:
<script defer src="./app.js"></script>
With this setup complete, we’ll have two methods at our disposal for executing the code we write in app.js:
-
Open the
index.htmlfile in your browser and access the console output in your browser’s dev tools. -
Use
nodeto execute theapp.jsfile directly by using this command in your terminal:
node app.js
While either method is acceptable, you should use the same method as your instructor for simplicity.