MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / askForGuess

Function askForGuess

javascript_games/guess.js:10–19  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8const readlineSync = require('readline-sync');
9
10function 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
21console.log('Guess the Number, by Al Sweigart al@inventwithpython.com');
22console.log();

Callers 1

guess.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected