SOURCE

const data = [1, 2, 3, 4, 5];
function takeVal(data, type) {
    const filterList = data.sort((a, b) => a - b);
    const min = filterList[0];
    const max = filterList[data.length -1];
    return { min, max }[type];
}
console.log('min', takeVal(data, 'min'));
console.log('max', takeVal(data, 'max'));
console 命令行工具 X clear

                    
>
console