shahoob/functionKit

View on GitHub
src/array/max.ts

Summary

Maintainability
A
1 hr
Test Coverage
/**
 * Get the largest number in an array
 * 
 * @param array A number array
 */
export function max(array: number[]) {
    return array.reduce((max, current) => {
        if (max < current) {
            return current;
        } else {
            return max;
        }
    });
}