-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
31 lines (25 loc) · 889 Bytes
/
main.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
let interval;
let condition = prompt('Set an interval? Ye / no');
if (['yes', 'ye', 'yas', 'ya'].includes(condition.toLowerCase())) {
let intervalTime = prompt('Enter seconds to repeat loop');
intervalTime = JSON.parse(intervalTime); // unstrigify
if (typeof(intervalTime) == 'number') {
alert('Press ESC key to remove the interval!');
window.addEventListener('keydown', (event) => {
if (event.keyCode == 27) {
clearInterval(interval);
alert('Interval cleared!');
}
});
interval = setInterval(() => {
console.log('interval is running!');
}, intervalTime * 1e3);
}
else {
alert('NUMBER NOT STRING BRO');
}
}
else if (['no', 'nah', 'naw'].includes(condition.toLowerCase())) {
alert('Oh ok sorry');
}
else alert('You not gonna answer? OK.');