How would I prevent the user from asking the same question twice? I already have it so they have to end their question with a question mark. It just needs to prevent them from asking the same question twice in a row doesn't have to permanent.
function Response() {
var answers = ["Ask again later...",
"Yes",
"No",
"It appears to be so",
"Reply is hazy, please try again",
"Yes, definitely",
"What is it you really want to know?",
"Outlook is good",
"My sources say no",
"Signs point to yes",
"Don't count on it",
"Cannot predict now",
"As i see it, yes",
"Better not tell you now",
"Concentrate ask again"
];
var number = Math.floor(Math.random() * 15);
if (document.getElementById("txtQuestion").value.indexOf("?") != -1) {
document.getElementById("lblDisplay").innerHTML = answers[number];
} else {
alert("Please use a question mark at the end of the question!");
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Magic 8 Ball</title>
</head>
<body>
<h1>Magic 8 Ball</h1>
<h2>What would you like to know?</h2>
<input id="txtQuestion" type="text" />
<br /><br />
<input type="button" value="Ask The 8 Ball" onclick="Response()" />
<br /><br />
<h3>The 8 Ball Says:</h3>
<h4 id="lblDisplay">Ask the 8 ball a question...</h4>
</body>
</html>