//JavaScript Node(12.x.x) var readline = require("readline"); // 创建输入输出接口 const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); // 监听控制台的输入 // 就是在用户输入一行 按下回车的时候就会触发的事件,他会将用户输入的数据通过回调函数传回来。 let rows = []; rl.on("line", function (line) { rows.push(line); if (rows.length != 0) { for (let i = 0; i < rows.length; i++) { console.log(rows[i][0].toLowerCase()); } } rows.length = 0 });