How to take in text input from a keyboard and store it into a variable?

前端 未结 7 2086
清酒与你
清酒与你 2020-12-30 05:43

I would just like something simple to read text from a keyboard and store it into a variable. So for:

var color = \'blue\'

I would like the

7条回答
  •  温柔的废话
    2020-12-30 06:16

    I would suggest the readline-sync module as well if you don't require something asynchronous.

    # npm install readline-sync
    
    const readline = require('readline-sync');
    
    let name = readline.question("What is your name?");
    
    console.log("Hi " + name + ", nice to meet you.");
    

提交回复
热议问题