Skip to content

Instantly share code, notes, and snippets.

@jamesfdickinson
Created February 14, 2014 06:24
Show Gist options
  • Save jamesfdickinson/8996608 to your computer and use it in GitHub Desktop.
Save jamesfdickinson/8996608 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<h1>Lesson 4 </h1>
<p>Make a choose your own adventure!</p>
<ol>
<li>Open the Javascript and output window</li>
<li>Click "Play"</li>
<li>Continue the adventure by creating 2 more prompts with if/else responses</li>
<li>Click "Play"</li>
</ol>
<input type="submit" id="byBtn" value="Play" onclick="play()" />
<div id="divPic" ></div>
</body>
</html>
function play(){
// Welcom the user!
alert("Welcome to... Snow White and Batmaaaaaan!");
alert("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
alert("Batman glares at you.");
var userAnswer = prompt("Are you feeling lucky, punk?");
if (userAnswer ==="yes")
{
alert("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!" );
}
else // Otherwise...
{
alert( "You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.");
}
}//end play function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment