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