Posted by: 6ixMediaSA
Comments: 0
Post Date: February 14, 2026
const secret = Math.floor(Math.random() * 10) + 1;
const readline = require('readline').createInterface({ input: process.stdin, output: process.stdout });
const ask = () => {
readline.question('Guess 1-10: ', (guess) => {
if (parseInt(guess) === secret) { console.log('Correct!'); readline.close(); }
else { console.log(guess < secret ? 'Higher!' : 'Lower!'); ask(); }
});
};
ask();


Leave a Reply