Write a function minBy(array, iteratee)
that looks through an array and returns the element
for which the provided iteratee function produces the smallest value.
⚠️ If the iteratee returns null
or undefined
for every element, the function should return undefined
.
Examples:
minBy([2, 3, 1, 4], (num) => num); // => 1 minBy([{ n: 1 }, { n: 2 }], (o) => o.n); // => { n: 1 } minBy([{ n: 1 }, { n: 2 }], (o) => o.m); // => undefined
JavaScript Function
No test results yet
Click "Run" to execute tests