-
Notifications
You must be signed in to change notification settings - Fork 1
/
guess.cjs.js
32 lines (29 loc) · 1.04 KB
/
guess.cjs.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
32
const readline = require('readline');
const Guess = () => {
return new Promise(resolve => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question("What do you think is the number? (Coins at stake)\n ", (userGuess) => {
resolve(userGuess);
console.log(`Loading...\n`);
rl.close();
});
});
}
const getStakeAmount = (accountBalance) => {
return new Promise(resolve => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(`What is the amount you want to stake? (max: 4)\n Curret amount balance: ${accountBalance}: `, (stakeAmount) => {
resolve(stakeAmount);
console.log(`You need to pay ${stakeAmount} before proceeding\n`);
rl.close();
});
});
}
module.exports.Guess = Guess;
module.exports.getStakeAmount = getStakeAmount;