Created
June 9, 2014 21:28
-
-
Save PlenipotentSS/1cfa870085113eececc7 to your computer and use it in GitHub Desktop.
Code Roulette adjusment
This file contains hidden or 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
<script> | |
var codeRoulette = function() { | |
var guess, answer; | |
guess = prompt("Welcome to Code Roulette. Please guess the number I am thinking of between 0 and 10. You have 3 chances to guess the correct number or you die."); | |
answer=Math.floor(Math.random()*11); | |
if(guess == answer) { | |
return"That is correct. Congratulations. You win $1 million."; | |
} | |
else { | |
return "Sorry, the correct number is " + answer; | |
} | |
} | |
var lives = 3; | |
while(lives>0){ | |
alert(codeRoulette()); | |
lives--; | |
} | |
if(lives ===0){ | |
alert("You Die!") | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment