<!------------------------------------------ File conditional_operators.html Illustrates the use of a condition -------------------------------------------> <html> <head> <title>conditional operators</title> <SCRIPT Language="JavaScript"> <!-- HIDE FROM OLDER BROWSERS // Define variables for rest of script var question="What is 10+10?"; var answer=20; var correct='<img src="ok.gif" width="96" height="89">'; var incorrect='<img src="wrong.gif" width="96" height="89">'; // Ask the question var response = prompt(question, ""); // Check the answer var output = (response == answer) ? correct : incorrect; // STOP HIDING FROM OLDER BROWSERS --> </script> </head> <body bgcolor="#FFFFFF"> <p> <h2>using conditional operators to test input</h2> <SCRIPT LANGUAGE="JavaScript"> <!--HIDE FROM OLDER BROWSERS document.write(output); // STOP HIDING FROM OLDER BROWSERS --> </script> <p> If you see a check mark, the answer you gave was correct; if you see an X, the answer was incorrect. <p> <hr> </body> </html>