Open jsartisan opened 1 month ago
index.ts
export function minBy<T>(array: T[], iteratee: (item: T) => number): T | undefined { if (array.length == 0) return; return array.reduce((previous, current) => { const previousValue = iteratee(previous); const currentValue = iteratee(current); if (previousValue > currentValue) { return current; } return previous; }); }
index.ts