random return an item of an array javascript code example
Example 1: get random item from array javascript
const randomElement = array[Math.floor(Math.random() * array.length)];
Example 2: get random element from array js
var item = items[Math.floor(Math.random() * items.length)];