Answers for "javascript pick item from array"

0

get random element from array js

var item = items[Math.floor(Math.random() * items.length)];
Posted by: Guest on October-28-2020
0

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)
Posted by: Guest on September-10-2020

Code answers related to "javascript pick item from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language