Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get random elements from array javascript

 const arr = myArray
      .map((a) => ({sort: Math.random(), value: a}))
      .sort((a, b) => a.sort - b.sort)
      .map((a) => a.value)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #elements #array #javascript
ADD COMMENT
Topic
Name
9+9 =