我正在学习一些节点核心模块,并且我已经编写了一个小命令行工具来测试readline
模块,但是在我的console.log()
输出中,我也在undefined
它下面收到:/
这是我的代码..
var rl = require('readline');
var prompts = rl.createInterface(process.stdin, process.stdout);
prompts.question("What is your favourite Star Wars movie? ", function (movie) {
var message = '';
if (movie = 1) {
message = console.log("Really!!?!?? Episode" + movie + " ??!?!!?!?!, Jar Jar Binks was a total dick!");
} else if (movie > 3) {
message = console.log("They were great movies!");
} else {
message = console.log("Get out...");
}
console.log(message);
prompts.close();
});
这就是我在控制台中看到的内容..
What is your favourite Star Wars movie? 1
Really!!?!?? Episode1 ??!?!!?!?!, Jar Jar Binks was a total dick!
undefined
我为什么要回来undefined
?