Contact: aviboots(AT)netvision.net.il
39,914 questions
51,847 answers
573 users
function getRandomItem(arr: any[]) : any{ const index = Math.floor(Math.random() * arr.length); return arr[index]; } const array = [1, 2, 5, 9, "a", "b", "c", "d"]; const result = getRandomItem(array); console.log(result); /* run: "c" */