Created
February 9, 2015 21:10
-
-
Save rodvan/a8fb2c9cbcd0c0ec1547 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/wugifekibu
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//Random number and then the machine will guess it. | |
var upper = 10000; | |
var randomNumber = getRandomNumber(upper); | |
var guess; | |
var attempts = 0; | |
function getRandomNumber(upper) { | |
return Math.floor( Math.random() * upper) + 1; | |
} | |
while ( guess !== randomNumber ) { | |
guess = getRandomNumber(upper); | |
attempts += 1; | |
} | |
document.write("<p> the random number was: " + randomNumber + "<p>"); | |
document.write("<p>It took the computer " + attempts + " attempts to get it right.</p>"); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
//Random number and then the machine will guess it. | |
var upper = 10000; | |
var randomNumber = getRandomNumber(upper); | |
var guess; | |
var attempts = 0; | |
function getRandomNumber(upper) { | |
return Math.floor( Math.random() * upper) + 1; | |
} | |
while ( guess !== randomNumber ) { | |
guess = getRandomNumber(upper); | |
attempts += 1; | |
} | |
document.write("<p> the random number was: " + randomNumber + "<p>"); | |
document.write("<p>It took the computer " + attempts + " attempts to get it right.</p>");</script></body> | |
</html> |
This file contains 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
//Random number and then the machine will guess it. | |
var upper = 10000; | |
var randomNumber = getRandomNumber(upper); | |
var guess; | |
var attempts = 0; | |
function getRandomNumber(upper) { | |
return Math.floor( Math.random() * upper) + 1; | |
} | |
while ( guess !== randomNumber ) { | |
guess = getRandomNumber(upper); | |
attempts += 1; | |
} | |
document.write("<p> the random number was: " + randomNumber + "<p>"); | |
document.write("<p>It took the computer " + attempts + " attempts to get it right.</p>"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment