diff --git a/Chapter 5/Exercise 5.1 b/Chapter 5/Exercise 5.1 new file mode 100644 index 0000000..db89ec2 --- /dev/null +++ b/Chapter 5/Exercise 5.1 @@ -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"); + } +}