我正在尝试获取一些代码,以根据他们对问题给出的答案在屏幕上显示特定消息。这是一个使用 Inquirer 包的节点应用程序,每次我运行节点应用程序时,它都会返回“未定义”。
{
type: "checkbox",
name: "channels",
message: "Which of these TV channels would you watch?!",
choices: ["Investigation Discovery", "CNN", "Fox News", "TLC"]
}
]).then(function (responses) {
for(let i = 0; i < responses.channels; i++) {
if (responses.channels === 0) {
console.log("You are probably smart");
}`enter code here`
else if (responses.channels === 1) {
console.log("You are probably well informed");
}
else if (responses.channels === 2) {
console.log("You are probably not very well informed");
}
else {
console.log("You are probably an idiot");
}
}
如前所述,它应该根据选择的选项在控制台中返回一条消息,但它只返回“未定义”。