Create loto.js

This commit is contained in:
tiennm99 committed 2025-12-21 09:55:19 +07:00
1 parent 77b70442ea
commit 761744cdc6
1 file changed
+23
+23
View File
@@ -0,0 +1,23 @@
function randomNumbers(num, from, to) {
let arr = Array.from({
length: to - from
}, (_, i) => from + i);
arr.sort(() => 0.5 - Math.random());
return arr.slice(0, num);
}
let arr = randomNumbers(90, 1, 91);
let i = 0;
const readline = require('readline');
readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.on('keypress', (str, key) => {
if (key.ctrl && key.name === 'c') {
console.log(JSON.stringify);
process.exit();
} else {
console.log(`Next number: ${arr[i++]}\n`);
}
});
console.log('Press any key...');