Skip to content

Instantly share code, notes, and snippets.

@sburbidg
Created June 9, 2014 18:04
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 sburbidg/4eb91de915e2d2e3673e to your computer and use it in GitHub Desktop.
Save sburbidg/4eb91de915e2d2e3673e to your computer and use it in GitHub Desktop.
<script>
//var butterfly, sure, answer, done, collected, correct, guess
collected = Math.floor(Math.random() *1000)
var butterfly = function() {
alert("Oh no, a bunch of butterflies escaped!")
}
var answer = confirm("Would you like to open the box?")
var done = false
while (!done){
if(answer) {
butterfly()
done = true
} else { var sure = confirm("Are you sure")
if(sure) {
alert("Your loss, but really...")
} else { butterfly()
done = true
}
}
}
alert("The butterflies need to be put back in the box so they don't die")
alert("There were 1000 in the box, collect as many as you can")
var guess = prompt("How many do you think you got back in the box?")
var correct = (guess == collected)
while(!correct){
if(guess >= (collected - 1000) && guess <= (collected - 800)) {
guess = prompt("Wow, so far off, it looks like you caught way more than that")
}
if(guess <= (collected + 1000) && guess >= (collected + 800)) {
guess = prompt("Wow, that's a little cocky, you didn't catch nearly that many")
}
if(guess >= (collected - 799) && guess <= (collected - 400)) {
guess = prompt("Give yourself more credit than that")
}
if(guess >= (collected - 399) && guess <= (collected - 50)) {
guess = prompt("Kinda close, try a little higher")
}
if(guess >= (collected - 49) && guess <= (collected - 10)) {
guess = prompt("You are pretty close, you caught just a bit more than that")
}
if(guess >= (collected - 9) && guess <= (collected - 1)) {
guess = prompt("I think it's just a few more")
}
if(guess <= (collected + 799) && guess >= (collected + 400)) {
guess = prompt("Haha, not nearly. Why don't you try a little lower")
}
if(guess <= (collected + 399) && guess >= (collected + 50)) {
guess = prompt("You didn't catch quite that many")
}
if(guess <= (collected + 49) && guess >= (collected + 10)) {
guess = prompt("You are pretty close, you caught just a bit less than that")
}
if(guess <= (collected + 9) && guess >= (collected + 1)) {
guess = prompt("I think it's just a few less")
}
if(guess == collected) {correct = true}
}
alert("Hey, good job, while the others fly free the butterflies you caught will be turned into makeup for birds")
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment