Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ I have 3 games in this repository, with the intention of hopefully making it so

First, I decided to do the classic "guess a number between 1 and 100" guessing game. The game allows 7 guesses for the user, and notifies the user if their guess is too high or too low. The game ends when the user either guesses correctly or runs out of guesses before they answer correctly. The user is notified of the outcome, and the program ends.

Add ability to select difficulty, returns answer at end of game.

Second, I decided to try to recreate one of the puzzles from my favorite childhood game: The Logical Journey of the Zoombinis. In this game, the player is given a list of pizza toppings, and they are asked to guess a random set of pizza toppings in a certain amount of tries. The game gives feedback based on if there is a topping wrong, and if there are no wrong toppings it will tell them if there are missing toppings. When the correct set is guessed or the user runs out of guesses, they are notified of the outcome and the program ends.

Finaly, I made a dice game in which the player is asked to guess a number that will be rolled on a simulated roll of 2 dice. They are then asked to bet an amount of money out of their remaining money, which starts at 100. If they guess correctly, they will recieve a payout based on the odds of rolling that number. If the player runs out of money, they are notified and the game ends.
Expand Down
13 changes: 8 additions & 5 deletions numberGuess.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<script>
var input;
var line1='Welcome to the guessing game! Try to guess the correct number from 1 to 100';
var difficulty = prompt('On a scale of 1-3, how hard would you like your game?');
var running=true;
var answer=Math.floor((Math.random()*100+1));
var highNum= (Math.pow(10, parseInt(difficulty)));
var line1='Welcome to the guessing game! Try to guess the correct number from 0 to ' + highNum;
var answer=Math.floor((Math.random()*highNum+1));
var guessesLeft=7;
var line2='Guesses remaining: '+guessesLeft;
var solved=false;

while(running==true){
if (solved==true){
alert('You were correct! Congratulations!');
alert('You were correct! Congratulations! The answer is' + answer);
running=false;
}
else if (guessesLeft==0){
alert('Sorry, you ran out of guesses.');
alert('Sorry, the answer was ' + answer);
running=false;
}
else{
Expand All @@ -32,4 +35,4 @@
}
}
}
</script>
</script>