Exercise 5.1

This commit is contained in:
Karan
2021-11-24 19:36:19 +05:30
committed by GitHub
parent a421bccb36
commit 9e5b119bdf
+16
View File
@@ -0,0 +1,16 @@
const max = 5;
const ranNumber = Math.floor(Math.random() * max) + 1;
//console.log(ranNumber);
let correct = false;
while (!correct) {
let guess = prompt("Guess a Number 1 - " + max);
guess = Number(guess);
if (guess === ranNumber) {
correct = true;
console.log("You got it " + ranNumber)
} else if (guess > ranNumber) {
console.log("Too high");
} else {
console.log("Too Low");
}
}