1var arr = [1, 2, 3];
2var max = arr.reduce(function(a, b) {
3 return Math.max(a, b);
4});
1// Getting min value
2var arr = [5,1,9,5,7];
3var min = Math.min(...arr);
4console.log(min); // 1
5
6// Getting max value
7var arr = [5,1,9,5,7];
8var min = Math.max(...arr);
9console.log(min); // 9
1var numbers = [1, 2, 3, 4];
2Math.max(...numbers) // 4
3Math.min(...numbers) // 1