Now we are getting a new random number each time we run the game, but it is a decimal number (also known as a float), and array indices can only be whole numbers (also known as an int or integer). To fix that, we can use another Math library function, floor, which rounds numbers down to the nearest integer.
- In the randomizeTreasure function, create a new variable after the randomNumber variable called randomTreasure.
- Set randomTreasure to numSpots times randomNumber, rounded down with Math.floor.
- Change the last index you had for digSpots to randomTreasure, and let the program send the event to the index that was randomly selected.