This function finds the largest number in an array.
JavaScript:
let maxItem = arr => Math.max(...arr);
// Example
console.log(maxItem([10, 20, 30, 2, 50])); // 50
console.log(maxItem([1.2, 0.2, 0.5, 1.1, 0.9])); // 1.2
TypeScript:
let maxItem = (arr: number[]): number => Math.max(...arr);
// Example
console.log(maxItem([10, 20, 30, 2, 50])); // 50
console.log(maxItem([1.2, 0.2, 0.5, 1.1, 0.9])); // 1.2