Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #statement #array #javascript
ADD COMMENT
Topic
Name
8+8 =