-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain008.js
34 lines (34 loc) · 1.09 KB
/
main008.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
33
34
console.log(chalk.italic.bold.cyan("Welcome To Number Guessing Game"));
console.warn(chalk.yellow("Let's Begain The Game"));
import chalk from "chalk";
import inquirer from "inquirer";
async function startFunc() {
const autoNum = Math.floor(Math.random() * 100);
const userNum = await inquirer.prompt([
{
type: "number",
name: "userGuess",
message: "Guess The Number & Type It"
}
]);
const { userGuess } = userNum;
console.log(userGuess, "Your Guess", autoNum, "SystemGuess");
if (userGuess === autoNum) {
console.log(chalk.bgGreen("Wow Your Is Correct Answer"));
}
else {
console.log(chalk.red("Better Luck Next Time TryAgain"));
}
}
async function startAgain() {
do {
await startFunc();
var agin = await inquirer
.prompt({
type: "input",
name: "restart",
message: "DO You Want To Continue? Press Y or N "
});
} while (agin.restart == "Y" || agin.restart == "y" || agin.restart == "YES" || agin.restart == "yes");
}
startAgain();