get random element from array typescript

Solutions on MaxInterview for get random element from array typescript by the best coders in the world

showing results for - "get random element from array typescript"
Greta
30 Sep 2016
1//get random value from array
2var colors = ["red","blue","green","yellow"];
3var randColor = colors[Math.floor(Math.random() * colors.length)];
4
Struan
19 Jul 2020
1const randomElement = array[Math.floor(Math.random() * array.length)];
similar questions
queries leading to this page
get random element from array typescript