Created
June 11, 2014 08:45
-
-
Save brmendez/06cc82f9dbca23cb6fe3 to your computer and use it in GitHub Desktop.
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
<html> | |
<header> | |
<script> | |
function startGameLoop() | |
{ | |
for (i=0; i<3; i++) | |
{ | |
brian() | |
} | |
} | |
function brian() | |
{ | |
var x = Math.random() | |
var y = x * 10 | |
var wholeNumber = Math.floor(y) | |
var result | |
result = playGame(wholeNumber) | |
if (true == result) | |
{ | |
alert("You guessed the RIGHT number"); | |
} | |
else | |
{ | |
alert("You guessed the WRONG number"); | |
} | |
} | |
function playGame(ownerNumberInput) | |
{ | |
var guessedNumber | |
guessedNumber = prompt("Hello, guess my number"); | |
if (guessedNumber == ownerNumberInput) | |
{ | |
return true; | |
} | |
else | |
{ | |
return false; | |
} | |
} | |
//////////////////////////////////////////////// | |
</script> | |
</header> | |
<body> | |
<form action=""> | |
<input type="button" value="Would you like to play a Game?" onclick="startGameLoop()"/> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment