Skip to content

Instantly share code, notes, and snippets.

@brmendez
Created June 11, 2014 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brmendez/06cc82f9dbca23cb6fe3 to your computer and use it in GitHub Desktop.
Save brmendez/06cc82f9dbca23cb6fe3 to your computer and use it in GitHub Desktop.
<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