Get a random unique value from a specified array.
You can use one of the hundred ways to get values at a specific index, or iterate over an array and get values in sequence.
|
|
But, what if you want to randomly get values from the array?
That is easy too.
|
|
However, you will see more repeating values than expected in the above logic (especially if you have a small array). To avoid repetitions, you can compare your current random index with previous random index, and change it if equal.
You may find such a logic useful when generating test data for a field that allows a specific set of values (e.g. City, Status etc.)