The example below displays a random item of text pulled from an array of items.
To illustrate, I’ve included a small number of colour idioms, which are stored in a JavaScript Array object. When the page loads, a JavaScript function calls a random idiom from the array, and writes it to an HTML description list element on the page.
In the example, I’ve included a button for the user to load another random idiom. The array of idioms is quite small, as this is only an illustration, so there will necessarily be some repetition.
Display a random colour idiom