-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathask.js
33 lines (31 loc) · 894 Bytes
/
ask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
process.stdout.write("Hello");
process.stdout.write(" world \n\n\n"); */
var question = [
"Wht's your name",
"wht's your fav hobby",
"wht's your preffered programming language"
];
var answers = [];
function answered(j){
process.stdout.write(`${answers[j]}`);
}
function ask(i){
process.stdout.write(`\n ${question[i]} >`);
}
process.stdin.on('data',function (data){
if(data.toString().trim() === ""){
console.log('please fill these fields above');
}else{
answers.push(data.toString().trim());
}
if(answers.length < question.length){
ask(answers.length);
}else{
process.exit();
}
});
process.on('exit',function(){
process.stdout.write(`You Go on ${answers[0]} ${answers[1]} ${answers[2]} \n\n`);
});
ask(0);