Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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
You can’t perform that action at this time.