Exercise Deja Vu: Initialize an integer to represent a favorite number and assign a value with a number of your choosing or you can assign a random number to this variable:
OR
Use prompt()
to ask the user to input a number, and store the result in a variable
Create an if-statement that if the guessed number is below the initial value, print out “too low”.
Create an else-if statement that if the number is higher than the initial value, print out “too high”.
Create an else statement that prints out “Congratulations!!!”.
Wait.. We already did this. Yes! But this isn’t as good as it could be. We need to make this number guessing game playable until the user guesses the correct number.
You are required to use a selection statement, loop, and at least one function. After you reach the required functionality, think of ways you could improve the game.
BONUS: Refactor your guessing game to be playable until a correct answer, without using a loop. BONUS: Integers? Boring. Allow for decimals. Let’s say the limit is the one-hundredth decimal place. BONUS: It’s not just a number. The user is guessing an rgb value (0-255). If you’re feeling adventurous, refactor your code to change the game. Be creative, there are no additional requirements.