Skip to content

Instantly share code, notes, and snippets.

@PlenipotentSS
Created June 9, 2014 21:28
Show Gist options
  • Save PlenipotentSS/1cfa870085113eececc7 to your computer and use it in GitHub Desktop.
Save PlenipotentSS/1cfa870085113eececc7 to your computer and use it in GitHub Desktop.
Code Roulette adjusment
<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