Enter the slots.html text from Figure 11.10 into a new Web page, then load the page in
Question:
Enter the slots.html text from Figure 11.10 into a new Web page, then load the page in the browser to verify that it behaves as described.
Modify your page so that it simulates a slot machine, with the player's credits displayed in a text span in the page. When the game begins, the number of credits should start at 20. Each spin of the slots should cost the player one credit. If all three slot images match, however, the player wins and is credited with 13 credits (for a net gain of 12 credits). In addition, an alert window should appear to notify the player of the winning spin. Augment the SpinSlots function so that the number of credits is updated appropriately on each spin.
As is the case with all organized gambling, the odds here favor the house. Since there are four different images that can appear in a slot, there is a 1 in 16 chance of all three slots coming up the same. Thus, you would expect (in the long run) for the player to win 1 out of every 16 spins. Consequently, the payoff of $13 does not quite offset the $16 cost of the spins. As a result, you are more likely to lose money (in the long run) than win money. Perform numerous simulations with your updated page to see if this pattern holds?
Step by Step Answer: