This is a complete js script I wrote while teaching myself js:
/* The Extremely Long Compliance Quiz (TELCOQ) copyright (c) 2013 by Miki Kocic. All
* rights reserved except that his program is being released under the GNU Public
* Licence version 2 or later, with the version later than 2 being at your
* discretion. */
// declare variables
var introString = "Welcome to The Extremely Long Compliance Quiz! This \
excruciatingly endless quiz tests whether you can follow instructions.";
var userPrompt = "Type in 'yes' to take the quiz or 'no' to skip taking it \
because you have better ways to waste your time.";
var outcomeOne = "By typing either 'yes' or 'no' rather than something else, you \
showed that you can follow instructions. You pass the quiz! Congratulations!";
var outcomeTwo = "I'm sorry that you don't want to take my quiz, but by typing \
either 'yes' or 'no' instead of something else, you took it whether you wanted \
to or not! How's that for infringing on your civil liberties? The good news is \
that you passed the quiz by showing that you know how to follow instructions.";
var outcomeThree = "By typing something other than 'yes' or 'no' as instructed, you \
took the quiz and flunked it by showing that you don't know how to follow \
instructions. Sawry!";
var UserChoice
var outputString
var closingMessage = "Thank you for using The Extremely Long Compliance Quiz. \
Have a nice day even if it's past midnight!";
// print intro message and request user input
alert(introString);
userChoice = prompt(userPrompt);
// main code
switch (userChoice) {
case "yes":
outputString = outcomeOne;
break;
case "no":
outputString = outcomeTwo;
break;
default:
outputString = outcomeThree;
break;
}
// print output and closing message and exit
alert(outputString);
alert(closingMessage);
Have fun with this thingamajig. I sure enjoyed writing it!
Miki