Line At A Time
Lesson 2: Variables with const
Variables with const Store a value in a variable and print it.
1const message = "Hi there";
2console.log(message);
Terminal
$ node main.js
Hi there
Every line, explained
const message = "Hi there";
const creates a variable: a named box that stores a value. const is short for "constant": once a value is stored, that name can never be given a new value. Modern JavaScript uses const for most things. The semicolon ; marks the end of the statement.
console.log(message);
console.log(...) prints whatever is inside the round brackets to the terminal, then moves to a new line. console is the terminal itself, log is the tool that writes to it, joined with a dot. No quotes around message here, so JavaScript prints what is stored in the variable, not the word message itself.