Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 149822

Removing commas from Array created with checkbox from Node Inquirer

$
0
0

I have the following inquirer prompt, which as far as I understands returns an array of strings:

 {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";
        }

And then I want to print the answer as follows:

let foods = answers.food ? "You chose the following: \n " + answers.food.map(option => "• " + option + "\n") : "";

Hoping to get something like:

You chose the following: • option1 • option2 • option3

And Instead I'm getting something like this:

• option1 ,• option2 ,• option3

Anyone has an Idea of how can I remove those annoying commas?


Viewing all articles
Browse latest Browse all 149822

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>