recursive prompt - Node Js

PHOTO EMBED

Sat Feb 06 2021 12:27:05 GMT+0000 (Coordinated Universal Time)

Saved by @samoisamoi12 #javascript #nodejs

var readline = require("readline");
var rl = readline.createInterface({input: process.stdin, output: process.stdout});

var program = function(){
    rl.question("type question", function(answer) {
        switch (answer){
            case "option 1":
                //action 1;
                break;
            case "exit option":
            	//previous action
            	return rl.close();
            default:
                //default action
        }
        program();
    });
}

program();
content_copyCOPY