Project Explanation

The code for this project starts by generating a random number between 0 and 20.

A switch statement is used to map each possible random number to a specific response. Dependent on the 'case' of the switch statement the src attribute of the eightBall image element is updated to point to a different image file containing the final message for the user.

Error Handling: A default case is included in the switch statement to catch any unexpected numbers, throwing an error to indicate a potential issue with the logic.

Finally, an event listener is attached to the oracleButton. The "mousedown" event is used, meaning that each time the user presses down on the button, the 'consult' function is executed, triggering a new divination. This setup creates an interactive experience where users can click the button to receive a random, pre-determined answer from the Magic 8-Ball.