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