()
| 8 | const readlineSync = require('readline-sync'); |
| 9 | |
| 10 | function askForGuess() { |
| 11 | while (true) { |
| 12 | let guess = readlineSync.question('> '); // Enter the guess. |
| 13 | |
| 14 | if (!isNaN(guess)) { |
| 15 | return Number(guess); // Convert string guess to an integer. |
| 16 | } |
| 17 | console.log('Please enter a number between 1 and 100.'); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | console.log('Guess the Number, by Al Sweigart al@inventwithpython.com'); |
| 22 | console.log(); |