我有以下询问者提示,据我所知,它返回一个字符串数组:
{name: "food",
message:"choose your favorite ➝ ",
type: "checkbox",
choices: ["option1", "option2", "option3", "option4", "option5", "option6"],
when: function(answers) {
return answers.client;
},
validate: function(choices) {
return choices.length <= 3 ? true : "Please select at least 3 choices";
}
然后我想按如下方式打印答案:
let foods = answers.food ? "You chose the following: \n " + answers.food.map(option => "• " + option + "\n") : "";
希望得到类似的东西:
您选择了以下选项: • option1 • option2 • option3
相反,我得到的是这样的:
• 选项 1 ,• 选项 2 ,• 选项 3
任何人都知道如何删除那些烦人的逗号?