-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
92 lines (71 loc) · 2.19 KB
/
index.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const { exec } = require("child_process");
const readline = require('readline');
const rl = readline.createInterface({
input : process.stdin,
output : process.stdout
});
setTimeout(driversTimer, 30000)
setTimeout(
() => {
console.log("Driver selector started: ");
},
30000
);
let drivers = []
let timerStopper = 0;
console.log("Please enter the names of the driver below");
console.log("You have 30 seconds to input thr drivers numbers");
let recursiveAsyncReadLine = function () {
rl.question('Names of the drivers: ', function (answer) {
drivers.push(answer);
if (answer == 'exit')
return rl.close();
recursiveAsyncReadLine();
});
};
recursiveAsyncReadLine();
function driversTimer(){
const driverSelector = Math.floor(Math.random() * drivers.length);
console.log(drivers[driverSelector]);
let index = drivers.indexOf(drivers[driverSelector]);
drivers.splice(index,1);
timerStopper++;
if(drivers.length > 0){
// setTimeout(driversTimer, 300000)
setTimeout(driversTimer, 6000)
}
exec("afplay Left.mp3");
}
//-----------------------------------------------------------
// rl.question(`What's your name? `, (name) => {
// rl.question(`What are you from? `, (country) => {
// console.log(`${name} is from ${country}`);
// rl.close();
// });
// });
// let i =0;
// rl.question('How many times to you want ot repeat: ', driverData)
// function driverData(driverAmount){
// while(i < driverAmount){
// rl.question("Names of the drivers: ",function(answer) {
// drivers.push(answer);
// console.log(drivers)
// });
// // console.log('Simone Ram');
// i++;
// }
// }
// var count = 0;
// while(count < 10){
// rl.question("What is your favourite food: ",function(answer) {
// console.log('Oh, so your favorite food is ' + answer);
// });
// count ++;
// }
// rl.question("Names of drivers: ", driversInput)
// function driversInput(driversName){
// drivers.push(driversName);
// // console.log(drivers)
// }
// driverData();
// let drivers = ["Harman","James","Jessica", "Kacper",'Roheel', "Simone", "Sukh", "Tim"]