function sample sample<T>(list: T[]): T | undefined Pick a random item from an array. Examples Example 1 const myList = [1, 2, 3, 4]; const randomItem = sample(myList); console.log(randomItem); // could be 1, 2, 3, or 4 console.log(sample([])); // undefined Type Parameters T Parameters list: T[] Return Type T | undefined