1let numbers = [4, 13, 27, 0, -5]; // Get max value of an array in Javascript
2
3Math.max.apply(null, numbers); // returns 27
4
1Math.max() function returns the largest of the zero or more numbers given as input parameters.
2Math.max(1,10,100); // return 100
1// Math.max
2finding maximum number
3
4console.log(Math.max(1, 3, 2));
5// expected output: 3
6
7console.log(Math.max(-1, -3, -2));
8// expected output: -1
9
10const array1 = [1, 3, 2];
11
12console.log(Math.max(...array1));
13// expected output: 3
1console.log(Math.max(1, 3, 2));
2// expected output: 3
3
4console.log(Math.max(-1, -3, -2));
5// expected output: -1
6
7const array1 = [1, 3, 2];
8
9console.log(Math.max(...array1));
10// expected output: 3