random element in js code example
Example 1: get random item from array javascript
const randomElement = array[Math.floor(Math.random() * array.length)];
Example 2: how to get a random statement from an array in javascript
// List your array items
let Testing1 = ["put","things","here"]
let Generate = Math.floor((Math.random() * Testing1.length)); // Generates a number of the array.
// logs the result
console.log(Testing1[Generate])