There are two different ways to do this:
1. Randomly pick a single one, 2. Let the entire array be randomly sorted
Note: The [ ] symbol defines an array in JavaScript, and { } defines an object
Randomly obtain one of the items in the array:
Randomly sort the entire array Array:
==========================================
There is a very convenient function shuffle() in PHP for shuffling arrays. This function is used in many situations, but JavaScript arrays do not have this method. It doesn’t matter if it is not available. You can extend one. Do it yourself and you will have enough food and clothing. .