Sunday 21 October 2018

Looping Inquirer.js Prompts

I tried to create a loop for inquirer.js for a command line application, where if certain conditions are satisfied, the application will loop to the start again. There is a second inquirer prompt where looping will be done according to the satisfied statement.inquirer .prompt(question1) .then(answers => { if (//condition satisfied){ //loop back to prompt question1. } inquirer .prompt(question2) .then(answers => { if (//condition satisfied){ //loop back to prompt question1. } else { //loop back to prompt question2. } }); }); For the first inquirer function, if the condition is met, I would like to loop back so the function is start over again. If condition is not met, then question2 will be asked by the next function.If the condition is met in this second function, I would again like to start over to the first function again. However, if it's not met ('else' statement), then I would like to ask the question2 again by looping back to the second function.The entire application will keep these looping operations until the user quits the program. However, I am having trouble implementing these looping action.

Submitted October 21, 2018 at 02:05PM by VickNicks

No comments:

Post a Comment