const arr = [1, 5, 3, 7, 2, 8];
const max = Math.max(...arr);
const min = Math.min(...arr);
console.log(max);
// 8
console.log(min);
// 1