Last active
August 29, 2015 14:02
-
-
Save NEWeber/5535ef558b3232f842f8 to your computer and use it in GitHub Desktop.
Revisions
-
NEWeber revised this gist
Jun 8, 2014 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,16 +6,13 @@ alert("Great! Let's get started."); alert("You've got three guesses to get the right answer. Let me get your question."); var guessIt = function(qaIndex) { //Here are the Questions and answers var questions = ["What year did Macbeth debut?", "Who said, 'Out, out damn spot!'?", "How many acts long is the play?"]; var answers = [1606, "Lady Macbeth", 5]; var guess guess = prompt(questions[qaIndex]); if(guess == answers[qaIndex]) { stopPlaying = true return "Nice work!"; @@ -34,7 +31,7 @@ return (Math.floor(Math.random() * 3)) } var gameIndex gameIndex = getIndex() for(tries = 1; tries < 4; tries++) { alert(guessIt(gameIndex)); -
NEWeber created this gist
Jun 8, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ <script> var playIt playIt = confirm("Welcome to the Macbeth Quiz! Do you want to play?"); if (playIt) { alert("Great! Let's get started."); alert("You've got three guesses to get the right answer. Let me get your question."); var guessIt = function(qaIndex) { //Here are the Questions and answers var questions = ["What year did Macbeth debut?", "Who said, 'Out, out damn spot!'?", "How many acts long is the play?"]; var answers = [1606, "Lady Macbeth", 5]; var guess guess = prompt(questions[qaIndex]); if(guess == answers[qaIndex]) { stopPlaying = true return "Nice work!"; } else { return "Sorry, try again"; } } //stopPlaying tracks if the user has gotten the question right yet and will end the program early if they have var stopPlaying stopPlaying = false //Generate a random number between 0 and 2 to get the index of the question var getIndex = function() { return (Math.floor(Math.random() * 3)) } var thisIndex gameIndex = getIndex() for(tries = 1; tries < 4; tries++) { alert(guessIt(gameIndex)); //Ends the program if the user has gotten the question right if (stopPlaying) { break } } } else { alert("I'm sorry to hear that. Goodbye.") } </script>