Exercise 5.1
This commit is contained in:
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user