-
Create a new file called
lesson2.js
-
Add this content into the file:
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.question('What is your name? ', (answer) => { console.log('Your name is ' + answer + '!'); rl.close(); });
-
Save the file.
-
Open up your Terminal (or Command Prompt in Windows).
-
Change directory to the folder where you kept the file.
-
Type:
node lesson2.js
-
See what happens.
Further Reading