Get a random item from an array

JavaScript version
const randomItem = (arr) => arr[(Math.random() * arr.length) | 0];
TypeScript version
const randomItem = <T,_>(arr: T[]): T => arr[(Math.random() * arr.length) | 0];