const max = (arr) => arr.reduce((acc, curr) => Math.max(acc, curr), Number.NEGATIVE_INFINITY);
let arr = [1, 2, 3, 4, 5];
console.log("参数为:", arr);
console.log("结果为:", max(arr));
const min = (arr) => arr.reduce((acc, curr) => Math.min(acc, curr), Number.POSITIVE_INFINITY);
let arr = [1, 2, 3, 4, 5];
console.log("参数为:", arr);
console.log("结果为:", min(arr));
const factorial = (n) => Array.from({ length: n }, (_, i) => i 1).reduce((acc, curr) => acc * curr, 1);
// Array.from({ length: n }, (_, i) => i 1) 生成数组数据 [1,2,3,4,5]
console.log("参数为:", 5);
console.log("结果为:", factorial(5));
const unique = (arr) => arr.reduce((acc, curr) => acc.includes(curr) ? acc : [...acc, curr], []);
let arr = [1, 2,3,4,2, 3, 4, 5];
console.log("参数为:", arr);
console.log("结果为:", unique(arr));