In Chapter 9, you created a magic.html page that simulated the behavior of a Magic 8-Ball. As

Question:

In Chapter 9, you created a magic.html page that simulated the behavior of a Magic 8-Ball. As written, your page completely ignores the user's question while randomly selecting from a list of possible responses. Modify your page so that it is less obvious that the entered questions are irrelevant to the page's execution. In particular, the function in the page should use an if statement to make sure the user entered a question. If not (i.e., the value accessed from the text box is the empty string), then the browser should open an alert box reminding the user to enter a question. However, if the user did enter a question (i.e., the text box is not empty), the page should proceed as before and display a randomly chosen answer. For example,

If (document.getElementById('questionBox').value == '') {

alert('You need to enter a question first!');

}

else {

// existing code for selecting and displaying an answer

}

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: