diff --git a/src/array/max.ts b/src/array/max.ts index 4fd95f1..05a9a38 100644 --- a/src/array/max.ts +++ b/src/array/max.ts @@ -15,8 +15,9 @@ declare global { Array.prototype.max = function (this: ToArray | T[], fn?: CallbackFn): R { const values = fn ? ((this as T[]).map(fn) as R[]) : (this as R[]); - let max = values.shift(); - for (const value of values) { + let max = values.first; + for (let i = 1; i < values.length; i++) { + const value = values[i]; if (compare(value, max!) > 0) max = value; } return max!; diff --git a/src/array/min.ts b/src/array/min.ts index 3b75d04..46e3946 100644 --- a/src/array/min.ts +++ b/src/array/min.ts @@ -15,8 +15,9 @@ declare global { Array.prototype.min = function (this: ToArray, fn?: CallbackFn): R { const values = fn ? ((this as T[]).map(fn) as R[]) : (this as R[]); - let min = values.shift(); - for (const value of values) { + let min = values.first; + for (let i = 1; i < values.length; i++) { + const value = values[i]; if (compare(value, min!) < 0) min = value; } return min!;