Last active
June 7, 2018 19:46
-
-
Save Ge0rg3/b2d3c36792c4216a8756e3b589ea4105 to your computer and use it in GitHub Desktop.
*Extremely* simple JS number guessing game.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var response = parseInt(prompt("Enter your number here.")); | |
let attempts = 0; | |
random = (Math.floor(Math.random()*10)); | |
while (response !== random) { | |
attempts++; | |
if (response > random) { | |
console.log(`Too high!`); | |
response = parseInt(prompt("Too high!")); | |
} else if (response < random) { | |
console.log(`Too low!`); | |
response = parseInt(prompt("Too low!")); | |
} if (response === random) { | |
alert(`Correct! This took you ${attempts} attempts!`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment