NODE
node
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
let number = Math.floor(Math.random() * 100) + 1;
let chances = 0;
console.log("in this game, You have to guess the right number between 1 and 100 and you have only 10 chances to guess")
console.log("")
while (chances <= 10)
{
let guess = prompt("Enter your guessed number between 1 and 100")
if (guess < number) {
chances++
console.log("")
console.log("your guessed number is less than the number that i have guessed")
console.log("")
console.log(`No. of remaining chances: ${10 - chances}`)
}
else if (guess > number) {
chances++
console.log("")
console.log("your guessed number is greater than the number that i have guessed")
console.log("")
console.log(`No. of remaining chances: ${10 - chances}`)
}
else {
chances++;
console.log("")
console.log(`Congratulatons❤️💖 You guessed it right👍 in ${chances} chances`)
}
console.log("")
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run