In the last lesson, you typed JavaScript into the Node REPL one line at a time and read each answer straight away. That’s great for trying things, but the REPL keeps no file of your program: its history recalls earlier lines, not a program you can save and rerun.
To keep your code, you put it in a file. A file containing JavaScript that you run with Node is called a script. You already ran one, the supplied check.js. In this lesson, you’ll create your own script, run it, change it, and run it again. You’ll use that loop to write every program in this course.
Create Your Script
Your script is the first line of the movie-night snack calculator you’re building in this course. For now, it only prints a message.
Open your js-course folder in VS Code if it isn’t open already. In the Explorer panel, click the scratch folder once, click the New File icon, type hello.js, and press Enter. Then type this line into the new file.
scratch/hello.js
console.log("Movie night starts at eight!");
Like the line you copied into check.js, it shows the text between the quotes in the terminal. As in the REPL, the quotes mark where the text starts and ends and aren’t part of the message. You’ll take console.log() apart in a later lesson.